FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    IViewFor

    trait · ferroui-reactiveui · v0.5.0

    trait IViewFor: IActivatableView
    

    A view that displays a view model (IViewFor). A view is shared as an Rc.

    This is the form of a view that does not name the type of its view model: the view model is an Rc<dyn Any>. A view of a known view model also implements IViewForOf<VM>, and the macro view_for! writes both traits (with IActivatableView) from the typed accessors.

    The trait is object safe, so that a view is held as Rc<dyn IViewFor>; it is Any (through IActivatableView), so that Rc<dyn IViewFor> upcasts to Rc<dyn Any> and downcasts to the type of the view.

    View source

    Members

    view_model

    fn view_model(self: &Self) -> Option<Rc<dyn Any>>
    

    The view model displayed by the view (the getter of ViewModel).

    Source

    set_view_model

    fn set_view_model(self: &Self, view_model: Option<Rc<dyn Any>>)
    

    Sets the view model displayed by the view (the setter of ViewModel). A typed view panics when view_model is of another type than its own, as the cast of upstream's views throws.

    Source

    as_view_for_of

    fn as_view_for_of(self: Rc<Self>) -> Option<Box<dyn Any>>
    

    The view as an Rc<dyn IViewForOf<VM>> in a Box<dyn Any>, for the type VM of view model it is typed for, or None for a view that names no type.

    Not an upstream member: upstream asks view is IViewFor<TViewModel> at run time, which Rust cannot ask of a trait object. view_for_of reads it; view_for! writes it, and a view implementing the traits by hand returns typed_view_for``::<VM, Self>(self).

    Source

    Availability

    Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.