# IViewLocator

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-reactiveui/binding/interfaces/trait-iviewlocator/

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

```rust
trait IViewLocator: IEnableLogger + Any
```

Resolves the views of view models (`IViewLocator`).

A view model held as an `Rc<dyn Any>` is resolved by `resolve_view`,
which only asks what was registered for its type without the service locator, and by
`resolve_view_unsafe`, which also asks the service locator. A
view model whose type is known is resolved by `resolve_view_typed`,
which the generic `resolve_view_of` calls.

The trait is object safe (the locator is a service, `Rc<dyn IViewLocator>`); it is `Any`, so
that `ViewLocatorMixins` finds the
`DefaultViewLocator` behind it.

Deviation (DEVIATIONS.md, ReactiveUI): the generic member `ResolveView<TViewModel>(TViewModel,
string?)` cannot be part of a trait object; it is `resolve_view_typed`,
which takes the view model type-erased with a [`ViewModelType`](/docs/0.5.0/api/ferroui-reactiveui/binding/interfaces/struct-viewmodeltype/) that stands for its
compile-time type.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/binding/interfaces/i_view_locator.rs#L25)

## Members

- [`resolve_view_typed`](#function-resolve_view_typed)
- [`resolve_view`](#function-resolve_view)
- [`resolve_view_unsafe`](#function-resolve_view_unsafe)

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

### resolve_view_typed

```rust
fn resolve_view_typed(self: &Self, view_model: Rc<dyn Any>, view_model_type: &ViewModelType, contract: Option<&str>) -> Option<Rc<dyn IViewFor>>
```

Resolves the view of `view_model` under `contract` (`None` for the default view) through
its compile-time type `view_model_type`, or `None` if there is no view
(`ResolveView<TViewModel>(TViewModel, string?)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/binding/interfaces/i_view_locator.rs#L29)

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

### resolve_view

```rust
fn resolve_view(self: &Self, view_model: Option<Rc<dyn Any>>, contract: Option<&str>) -> Option<Rc<dyn IViewFor>>
```

Resolves the view of `view_model` by its run-time type, without the service locator, or
`None` if there is no view or no view model (`ResolveView(object?, string?)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/binding/interfaces/i_view_locator.rs#L33)

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

### resolve_view_unsafe

```rust
fn resolve_view_unsafe(self: &Self, view_model: Option<Rc<dyn Any>>, contract: Option<&str>) -> Option<Rc<dyn IViewFor>>
```

Resolves the view of `view_model` by its run-time type as
`resolve_view` does, then through the service locator
(`ResolveViewUnsafe(object?, string?)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/binding/interfaces/i_view_locator.rs#L38)

## Trait implementations

- [`IViewLocator`](/docs/0.5.0/api/ferroui-reactiveui/binding/interfaces/trait-iviewlocator/)

## Availability

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