# ViewMappingBuilder

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-reactiveui/binding/view/struct-viewmappingbuilder/

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

```rust
struct ViewMappingBuilder<'a>
```

Registers the mappings of view models to views on a [`DefaultViewLocator`](/docs/0.5.0/api/ferroui-reactiveui/binding/view/struct-defaultviewlocator/), each method
returning the builder to chain the calls (`ViewMappingBuilder`).

Deviation (DEVIATIONS.md, ReactiveUI): the builder borrows its locator. The overloads without a
contract are the same methods with `None`.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/binding/view/view_mapping_builder.rs#L14)

## Members

- [`new`](#function-new)
- [`map`](#function-map)
- [`map_factory`](#function-map_factory)
- [`map_from_service_locator`](#function-map_from_service_locator)

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

### new

```rust
fn new(locator: &'a DefaultViewLocator) -> Self
```

A builder that registers on `locator` (`ViewMappingBuilder(DefaultViewLocator)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/binding/view/view_mapping_builder.rs#L27)

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

### map

```rust
fn map<VM: 'static, V: IViewFor + Default>(self: &Self, contract: Option<&str>) -> &Self
```

Maps the view model type `VM`, under `contract` (`None` for the default), to a new view of
type `V`, replacing an existing mapping (`Map<TViewModel, TView>(string?)`).

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

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

### map_factory

```rust
fn map_factory<VM: 'static>(self: &Self, factory: impl Fn() -> Rc<dyn IViewFor> + 'static, contract: Option<&str>) -> &Self
```

Maps the view model type `VM`, under `contract`, to the view `factory` creates
(`Map<TViewModel>(Func<IViewFor>, string?)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/binding/view/view_mapping_builder.rs#L40)

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

### map_from_service_locator

```rust
fn map_from_service_locator<VM: 'static, V: IntoViewFor + ?Sized + 'static>(self: &Self, contract: Option<&str>, service_contract: Option<&str>) -> &Self
```

Maps the view model type `VM`, under `contract`, to the view the service locator gives for
the service type `V` under `service_contract` (`None` for the registration without a
contract), asked each time the mapping resolves
(`MapFromServiceLocator<TViewModel, TView>(string?, string?)`). `V` is a view type or a
trait object of one (`dyn IViewForOf<VM>`).

A view that is not registered panics with an `InvalidOperationException` message when the
mapping resolves, rather than resolving to nothing or to a view registered under another
contract.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/binding/view/view_mapping_builder.rs#L54)

## Trait implementations

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

## Availability

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