FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    ViewRegistrations

    struct · ferroui-reactiveui · v0.5.0

    struct ViewRegistrations
    

    The views of view models, collected into one GeneratedViewDispatch: what upstream's source generator builds from the classes that implement IViewFor<T>.

    use ferroui_reactiveui::{view_for, DefaultViewLocator, IViewLocator, ViewContract, ViewRegistrationOptions, ViewRegistrations};
    use std::any::Any;
    use std::cell::RefCell;
    use std::rc::Rc;
    
    struct TodoViewModel;
    
    #[derive(Default)]
    struct TodoView {
        view_model: RefCell<Option<Rc<TodoViewModel>>>,
    }
    view_for!(TodoView, TodoViewModel, view_model);
    
    ViewRegistrations::new()
        .register::<TodoViewModel, TodoView>(ViewRegistrationOptions::new())
        .register::<TodoViewModel, TodoView>(ViewRegistrationOptions::new().with_contract(ViewContract::new("compact")))
        .apply();
    
    let view = DefaultViewLocator::new().resolve_view(Some(Rc::new(TodoViewModel) as Rc<dyn Any>), Some("compact"));
    assert!(view.is_some());
    

    View source

    Members

    new

    fn new() -> Self
    

    No registration.

    Source

    register

    fn register<VM: 'static, V: IViewForOf<VM> + Default>(self: Self, options: ViewRegistrationOptions) -> Self
    

    Registers the view type V for the view model type VM, created with Default.

    Source

    register_with

    fn register_with<VM: 'static, V: IViewForOf<VM>>(self: Self, factory: impl Fn() -> Rc<V> + 'static, options: ViewRegistrationOptions) -> Self
    

    Registers the views factory creates for the view model type VM. A registration with ExcludeFromViewRegistration is skipped; one with SingleInstanceView creates its view once, on its first resolution.

    Source

    dispatch

    fn dispatch(self: Self) -> GeneratedViewDispatch
    

    The lookup of the registered views: the first registration of the type of the view model under the contract gives the view.

    Source

    apply

    fn apply(self: Self)
    

    Registers the lookup with DefaultViewLocator::set_generated_view_dispatch, as upstream's generated module initializer does.

    Source

    Trait implementations

    • Send
    • Sync
    • Freeze
    • UnsafeUnpin
    • Unpin
    • UnwindSafe
    • RefUnwindSafe
    • Borrow<T>
    • BorrowMut<T>
    • Into<U>
    • From<T>
    • TryInto<U>
    • TryFrom<U>
    • Any
    • Default
    • Debug

    Availability

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