# IServiceProvider

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/metadata/trait-iserviceprovider/

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

```rust
trait IServiceProvider
```

Retrieves service objects by the type of their handle.

A service is identified by the Rust type of the handle it is used
through, normally the handle of a contract (`Rc<dyn IProvideValueTarget>`,
`Rc<dyn IRootObjectProvider>`, `Rc<dyn INameScope>`). The provider returns
the handle boxed as `Any`; the box holds exactly a value of the
requested type.

```ignore
let target: Option<Rc<dyn IProvideValueTarget>> = service_provider.get_service_of();
```

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

## Members

- [`get_service`](#function-get_service)

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

### get_service

```rust
fn get_service(self: &Self, service_type: TypeId) -> Option<Rc<dyn Any>>
```

Gets the service whose handle type is `service_type`, or `None` if
the provider has no such service. The returned box holds a value of
exactly the type identified by `service_type`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/metadata/service_provider.rs#L22)

## Trait implementations

- [`IServiceProvider`](/docs/0.5.0/api/ferroui-base/metadata/trait-iserviceprovider/)

## Availability

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