moonrockz/diagrams/projection does not have a README file

    Appearance

    pub struct Appearance {
    status : Status?
    fill : Paint?
    stroke : Paint?
    ink : Paint?
    } derive(Eq,
    Debug
    )

    The semantic appearance of a visual. Absent properties keep the renderer's baseline for the element; status sets all three before explicit paints.

    Appearance::equal

    fn Appearance::equal(Appearance, Appearance) -> Bool
    automatically derived

    Appearance::is_baseline

    fn Appearance::is_baseline(self : Appearance) -> Bool

    True when the appearance changes nothing.

    Appearance::new

    fn Appearance::new(status? : Status, fill? : Paint, stroke? : Paint, ink? : Paint) -> Appearance

    Appearance::not_equal

    fn Appearance::not_equal(x : Appearance, y : Appearance) -> Bool
    automatically derived

    Appearance::to_repr

    automatically derived

    Context

    pub struct Context[A, V] {
    model : Model
    state : A
    view : V
    }

    The immutable inputs that a policy sees.

    Decoration

    pub(all) enum Decoration {
    Outline(Paint)
    Badge(String, Paint)
    } derive(Eq,
    Debug
    )

    An independent visual added to an element. Decorations coexist by key.

    Decoration::equal

    fn Decoration::equal(Decoration, Decoration) -> Bool
    automatically derived

    Decoration::not_equal

    fn Decoration::not_equal(x : Decoration, y : Decoration) -> Bool
    automatically derived

    Decoration::to_repr

    automatically derived

    Model

    A diagram and its index: one immutable model revision. Handles that view state holds come from tree.

    Override

    pub struct Override {
    target :
    Handle

    label : String?
    shape : String?
    status : Status?
    fill : Paint?
    stroke : Paint?
    ink : Paint?
    hidden : Bool?
    collapsed : Bool?
    decorations : ReadOnlyArray[(String, Decoration)]
    } derive(Eq,
    Debug
    )

    A partial override for one element. An absent property inherits: first from earlier overrides of the same element, then from the baseline.

    Override::equal

    fn Override::equal(Override, Override) -> Bool
    automatically derived

    Override::new

    fn Override::new(target :
    Handle
    , label? : String, shape? : String, status? : Status, fill? : Paint, stroke? : Paint, ink? : Paint, hidden? : Bool, collapsed? : Bool, decorations? : ArrayView[(String, Decoration)]) -> Override

    label and shape change layout inputs. collapsed folds a container; hidden removes an element from rendering only. Decorations are keyed by a name key that is unique within one override.

    Override::not_equal

    fn Override::not_equal(x : Override, y : Override) -> Bool
    automatically derived

    Override::to_repr

    automatically derived

    Paint

    pub(all) enum Paint {
    Status(Status)
    Literal(String)
    Variants(dark~ : String, light~ : String)
    } derive(Eq,
    Debug
    )

    A color reference. Status resolves to the matching property of a status role in the selected theme variant; Literal is one CSS hex color for both variants; Variants gives a dark and a light CSS hex color.

    Paint::equal

    fn Paint::equal(Paint, Paint) -> Bool
    automatically derived

    Paint::not_equal

    fn Paint::not_equal(x : Paint, y : Paint) -> Bool
    automatically derived

    Paint::to_repr

    automatically derived

    Policy

    pub struct Policy[A, V] {
    // private fields
    }

    A pure visual policy. Policies compose in the order the caller gives them.

    Policy::each

    A policy that decides one element at a time, in model order.

    Policy::new

    fn[A, V] Policy::new(apply : (Context[A, V]) -> Array[Override]) -> Policy[A, V]

    ProjectionError

    pub(all) enum ProjectionError {
    Index(String)
    RevisionMismatch
    DuplicateKey(String)
    } derive(Eq,
    Debug
    )

    Why a projection failed. A failed projection changes nothing.

    ProjectionError::equal

    automatically derived

    ProjectionError::message

    fn ProjectionError::message(self : ProjectionError) -> String

    ProjectionError::not_equal

    fn ProjectionError::not_equal(x : ProjectionError, y : ProjectionError) -> Bool
    automatically derived

    ProjectionError::to_repr

    automatically derived

    Role

    pub(all) enum Role {
    Body
    Decoration(String)
    } derive(Eq,
    Debug
    )

    Role::equal

    fn Role::equal(Role, Role) -> Bool
    automatically derived

    Role::not_equal

    fn Role::not_equal(x : Role, y : Role) -> Bool
    automatically derived

    Role::to_repr

    automatically derived

    Session

    pub struct Session[A, V] {
    // private fields
    }

    An explicit reactive session. It owns the current inputs and the last successful view. Each update replaces inputs atomically and recomputes the full projection; a failed update keeps both the inputs and the view.

    Session::error

    fn[A, V] Session::error(self : Session[A, V]) -> ProjectionError?

    The error of the last update, if it failed.

    Session::model

    fn[A, V] Session::model(self : Session[A, V]) -> Model

    Session::new

    fn[A, V] Session::new(model : Model, state : A, view : V, policies? : ArrayView[Policy[A, V]]) -> Result[Session[A, V], ProjectionError]

    Session::revision

    fn[A, V] Session::revision(self : Session[A, V]) -> Int

    The input revision of the last successful view. It starts at 1 and grows by one for each successful update.

    Session::state

    fn[A, V] Session::state(self : Session[A, V]) -> A

    Session::update

    fn[A, V] Session::update(self : Session[A, V], model? : Model, state? : A, view? : V, policies? : ArrayView[Policy[A, V]]) -> Result[View, ProjectionError]

    Replace any inputs at once. Absent inputs keep their current value. A new model revision needs view state whose handles come from that revision; an override that names an older revision fails with RevisionMismatch.

    Session::view

    fn[A, V] Session::view(self : Session[A, V]) -> View

    The last successful view.

    Session::view_state

    fn[A, V] Session::view_state(self : Session[A, V]) -> V

    Status

    pub(all) enum Status {
    Active
    Selected
    Warning
    Failed
    } derive(Eq,
    Debug
    )

    Semantic status roles. A rendering adapter resolves them against its theme; they never change an element's semantic family.

    Status::equal

    fn Status::equal(Status, Status) -> Bool
    automatically derived

    Status::not_equal

    fn Status::not_equal(x : Status, y : Status) -> Bool
    automatically derived

    Status::to_repr

    automatically derived

    View

    pub struct View {
    model : Model
    layout :
    Diagram

    visuals : ReadOnlyArray[Visual]
    revision : Int
    findings : ReadOnlyArray[
    Diagnostic
    ]
    }

    A logical view: the model revision, the layout input after label, shape, collapse and hiding overrides, and one visual per element and decoration.

    View::equivalent

    fn View::equivalent(self : View, other : View) -> Bool

    True when both views have equal layout inputs, visuals and findings for the same model revision. A session result equals a fresh projection.

    View::visual

    fn View::visual(self : View, key : String) -> Visual?

    View::visuals_of

    fn View::visuals_of(self : View, handle :
    Handle
    ) -> ReadOnlyArray[Visual]

    The visuals whose origin is handle: its body first, then decorations.

    Visual

    pub struct Visual {
    key : String
    origin :
    Handle

    role : Role
    element :
    Element

    label : String?
    shape : String?
    appearance : Appearance
    decoration : Decoration?
    hidden : Bool
    collapsed : Bool
    collapsed_into :
    Handle
    ?
    } derive(Eq,
    Debug
    )

    One visual element of a view. Several visuals can share an origin.

    Visual::equal

    fn Visual::equal(Visual, Visual) -> Bool
    automatically derived

    Visual::not_equal

    fn Visual::not_equal(x : Visual, y : Visual) -> Bool
    automatically derived

    Visual::to_repr

    automatically derived

    apply_overrides

    fn apply_overrides(model : Model, overrides : ArrayView[Override], revision? : Int) -> Result[View, ProjectionError]

    Apply overrides in order. Use it when overrides arrive as data.

    project

    fn[A, V] project(model : Model, state : A, view : V, policies? : ArrayView[Policy[A, V]], revision? : Int) -> Result[View, ProjectionError]

    Project a model with explicit state, view state and policies. The result derives only from these inputs; projection runs no action and never changes the model.

    visual_key

    fn visual_key(ordinal : Int, role : Role) -> String

    The key of a visual: origin ordinal, role and name key.