# FerroLocator

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/struct-ferrolocator/

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

```rust
struct FerroLocator
```

A scoped service registry.

Services are keyed by the `TypeId` of the service type, which can be a
concrete type (`Foo`, fetched as `Rc<Foo>`) or a trait object type
(`dyn IFoo`, fetched as `Rc<dyn IFoo>`):

```ignore
FerroLocator::current_mutable().bind::<dyn IFoo>().to_constant(Rc::new(Foo::new()));
let foo: Option<Rc<dyn IFoo>> = FerroLocator::current().get_service::<dyn IFoo>();
```

Like the rest of the object model the locator is per-thread: the current
locator and its registrations are only visible on the thread that made
them.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/ferro_locator.rs#L39)

## Members

- [`current`](#function-current)
- [`set_current`](#function-set_current)
- [`current_mutable`](#function-current_mutable)
- [`set_current_mutable`](#function-set_current_mutable)
- [`new`](#function-new)
- [`with_parent_scope`](#function-with_parent_scope)
- [`bind`](#function-bind)
- [`bind_to_self`](#function-bind_to_self)
- [`bind_to_self_singleton`](#function-bind_to_self_singleton)
- [`enter_scope`](#function-enter_scope)

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

### current

```rust
fn current() -> Rc<dyn IFerroDependencyResolver>
```

The resolver services are looked up in.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/ferro_locator.rs#L68)

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

### set_current

```rust
fn set_current(value: Rc<dyn IFerroDependencyResolver>)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/ferro_locator.rs#L72)

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

### current_mutable

```rust
fn current_mutable() -> Rc<FerroLocator>
```

The locator services are registered in.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/ferro_locator.rs#L78)

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

### set_current_mutable

```rust
fn set_current_mutable(value: Rc<FerroLocator>)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/ferro_locator.rs#L82)

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

### new

```rust
fn new() -> Self
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/ferro_locator.rs#L87)

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

### with_parent_scope

```rust
fn with_parent_scope(parent_scope: Rc<dyn IFerroDependencyResolver>) -> Self
```

Creates a locator that falls back to `parent_scope` for services it
has no registration for.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/ferro_locator.rs#L93)

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

### bind

```rust
fn bind<T: ?Sized + 'static>(self: &Self) -> RegistrationHelper<'_, T>
```

Starts the registration of the service type `T`, which may be a trait
object type.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/ferro_locator.rs#L104)

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

### bind_to_self

```rust
fn bind_to_self<T: 'static>(self: &Self, constant: Rc<T>) -> &FerroLocator
```

Registers `constant` as the service of its own type.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/ferro_locator.rs#L109)

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

### bind_to_self_singleton

```rust
fn bind_to_self_singleton<T: Default + 'static>(self: &Self) -> &FerroLocator
```

Registers a lazily created instance of `T` as the service of its own
type.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/ferro_locator.rs#L115)

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

### enter_scope

```rust
fn enter_scope() -> Rc<dyn IDisposable>
```

Makes a new locator, whose parent is the current resolver, the
current one. Disposing the returned value, or dropping its last
handle, restores the previous resolver and locator (once).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/ferro_locator.rs#L122)

## Trait implementations

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

## Availability

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