# ViewRegistrar

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-reactiveui-controls/struct-viewregistrar/

**struct** · [`ferroui-reactiveui-controls`](/docs/0.5.0/api/ferroui-reactiveui-controls/) · v0.5.0

```rust
struct ViewRegistrar
```

Registers the views of assemblies with a dependency resolver (`ViewRegistrar`).

A view is registered as `IViewFor<TViewModel>` of the view model it implements, under the
contract it declares. Resolution prefers the service locator and falls back to the
constructor, so a view with no registration of its own is still constructible.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI.Controls/view_registrar.rs#L99)

## Members

- [`register_views`](#function-register_views)
- [`register_views_internal`](#function-register_views_internal)
- [`find_view_for_interface`](#function-find_view_for_interface)
- [`get_view_contract`](#function-get_view_contract)
- [`create_view`](#function-create_view)
- [`create_view_after_resolution_failure`](#function-create_view_after_resolution_failure)
- [`create_view_with_activator`](#function-create_view_with_activator)

<a id="function-register_views"></a>

### register_views

```rust
fn register_views(resolver: Option<&dyn IMutableDependencyResolver>, assemblies: Option<&[Rc<ViewAssembly>]>)
```

Registers the views of `assemblies` with `resolver` when both are available
(`RegisterViews`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI.Controls/view_registrar.rs#L104)

<a id="function-register_views_internal"></a>

### register_views_internal

```rust
fn register_views_internal(resolver: &dyn IMutableDependencyResolver, assemblies: &[Rc<ViewAssembly>])
```

Registers every view of `assemblies` that is neither abstract nor an interface
(`RegisterViewsInternal`). An assembly given twice is registered once.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI.Controls/view_registrar.rs#L117)

<a id="function-find_view_for_interface"></a>

### find_view_for_interface

```rust
fn find_view_for_interface(view_type: &ViewAssemblyType) -> Option<&std::rc::Rc<dyn Fn(&dyn IMutableDependencyResolver) -> ()>>
```

The registration of `IViewFor<TViewModel>` of a type, `None` when the type is not a view
(`FindViewForInterface`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI.Controls/view_registrar.rs#L140)

<a id="function-get_view_contract"></a>

### get_view_contract

```rust
fn get_view_contract(view_type: &ViewAssemblyType) -> Option<&str>
```

The contract a view declares, `None` for the default (`GetViewContract`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI.Controls/view_registrar.rs#L145)

<a id="function-create_view"></a>

### create_view

```rust
fn create_view<V: 'static>(activator: fn() -> Rc<V>) -> Rc<V>
```

Resolves a view of type `V` from the service locator, or creates it with `activator`
(`CreateView`). A failure of the locator is logged and falls back to the constructor.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI.Controls/view_registrar.rs#L151)

<a id="function-create_view_after_resolution_failure"></a>

### create_view_after_resolution_failure

```rust
fn create_view_after_resolution_failure<V: 'static>(activator: fn() -> Rc<V>, error: &str) -> Rc<V>
```

Logs a failure of the service locator and creates the view with its constructor
(`CreateViewAfterResolutionFailure`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI.Controls/view_registrar.rs#L170)

<a id="function-create_view_with_activator"></a>

### create_view_with_activator

```rust
fn create_view_with_activator<V: 'static>(activator: fn() -> Rc<V>) -> Rc<V>
```

Creates the view with its constructor (`CreateViewWithActivator`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI.Controls/view_registrar.rs#L181)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `ErasedDestructor`
- `IntoEither`

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
