# service

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/metadata/function-service/

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

```rust
fn service<T: 'static>(service_type: std::any::TypeId, handle: impl FnOnce() -> T) -> Option<std::rc::Rc<dyn Any>>
```

Boxes a service handle for `IServiceProvider::get_service` if it is the
requested one. Meant for implementations:

```ignore
fn get_service(&self, service_type: TypeId) -> Option<Rc<dyn Any>> {
    service(service_type, || self.name_scope.clone())
        .or_else(|| service(service_type, || self.root_object_provider()))
}
```

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

## Availability

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