# ServiceDescriptor

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-dependency-injection/struct-servicedescriptor/

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

```rust
struct ServiceDescriptor
```

A registration. Construct typed factories with `new` or `from_factory`; erased registration
exists for adapters. Instance registrations are externally owned and never disposed.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DependencyInjection/service_descriptor.rs#L89)

## Members

- [`new`](#function-new)
- [`keyed`](#function-keyed)
- [`from_erased`](#function-from_erased)
- [`instance`](#function-instance)
- [`enumerable_instance`](#function-enumerable_instance)
- [`from_factory`](#function-from_factory)
- [`with_key`](#function-with_key)
- [`with_dependencies`](#function-with_dependencies)
- [`with_implementation`](#function-with_implementation)
- [`with_disposal`](#function-with_disposal)
- [`with_async_disposal`](#function-with_async_disposal)
- [`on_dispose`](#function-on_dispose)
- [`on_dispose_async`](#function-on_dispose_async)
- [`implementation_type`](#function-implementation_type)
- [`implementation_instance`](#function-implementation_instance)
- [`implementation_factory`](#function-implementation_factory)
- [`service_type`](#function-service_type)
- [`service_key`](#function-service_key)
- [`lifetime`](#function-lifetime)
- [`is_keyed_service`](#function-is_keyed_service)
- [`dependencies`](#function-dependencies)

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

### new

```rust
fn new<S: ?Sized + 'static, F>(lifetime: ServiceLifetime, factory: F) -> Self
where F: Fn(&ServiceProvider) -> ServiceResult<Rc<S>> + 'static
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DependencyInjection/service_descriptor.rs#L103)

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

### keyed

```rust
fn keyed<S: ?Sized + 'static, F>(lifetime: ServiceLifetime, key: Option<ServiceKey>, factory: F) -> Self
where F: Fn(&ServiceProvider, Option<&ServiceKey>) -> ServiceResult<Rc<S>> + 'static
```



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

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

### from_erased

```rust
fn from_erased(identifier: ServiceIdentifier, lifetime: ServiceLifetime, factory: impl Fn(&ServiceProvider, Option<&ServiceKey>) -> ServiceResult<ErasedService> + 'static) -> Self
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DependencyInjection/service_descriptor.rs#L121)

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

### instance

```rust
fn instance<S: ?Sized + 'static>(value: Rc<S>) -> Self
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DependencyInjection/service_descriptor.rs#L141)

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

### enumerable_instance

```rust
fn enumerable_instance<S: ?Sized + 'static>(values: Vec<Rc<S>>) -> Self
```

Explicit enumerable registration overrides the collection synthesized from individual services.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DependencyInjection/service_descriptor.rs#L149)

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

### from_factory

```rust
fn from_factory<S: ?Sized + 'static>(lifetime: ServiceLifetime, factory: ObjectFactory<S>) -> Self
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DependencyInjection/service_descriptor.rs#L161)

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

### with_key

```rust
fn with_key(self: Self, key: Option<ServiceKey>) -> Self
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DependencyInjection/service_descriptor.rs#L169)

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

### with_dependencies

```rust
fn with_dependencies(self: Self, dependencies: Vec<Dependency>) -> Self
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DependencyInjection/service_descriptor.rs#L173)

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

### with_implementation

```rust
fn with_implementation<I: ?Sized + 'static>(self: Self) -> Self
```

Identity used by TryAddEnumerable to distinguish implementations of the same service.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DependencyInjection/service_descriptor.rs#L178)

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

### with_disposal

```rust
fn with_disposal<S: ?Sized + IDisposable + 'static>(self: Self) -> Self
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DependencyInjection/service_descriptor.rs#L182)

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

### with_async_disposal

```rust
fn with_async_disposal<S: ?Sized + IAsyncDisposable + 'static>(self: Self) -> Self
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DependencyInjection/service_descriptor.rs#L185)

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

### on_dispose

```rust
fn on_dispose<S: ?Sized + 'static>(self: Self, dispose: impl Fn(&S) -> () + 'static) -> Self
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DependencyInjection/service_descriptor.rs#L188)

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

### on_dispose_async

```rust
fn on_dispose_async<S: ?Sized + 'static>(self: Self, dispose: impl Fn(Rc<S>) -> DisposeTask + 'static) -> Self
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DependencyInjection/service_descriptor.rs#L203)

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

### implementation_type

```rust
fn implementation_type(self: &Self) -> Option<ServiceType>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DependencyInjection/service_descriptor.rs#L221)

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

### implementation_instance

```rust
fn implementation_instance(self: &Self) -> Option<ErasedService>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DependencyInjection/service_descriptor.rs#L224)

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

### implementation_factory

```rust
fn implementation_factory(self: &Self) -> Option<crate::service_descriptor::ErasedFactory>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DependencyInjection/service_descriptor.rs#L227)

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

### service_type

```rust
fn service_type(self: &Self) -> ServiceType
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DependencyInjection/service_descriptor.rs#L234)

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

### service_key

```rust
fn service_key(self: &Self) -> Option<&ServiceKey>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DependencyInjection/service_descriptor.rs#L237)

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

### lifetime

```rust
fn lifetime(self: &Self) -> ServiceLifetime
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DependencyInjection/service_descriptor.rs#L240)

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

### is_keyed_service

```rust
fn is_keyed_service(self: &Self) -> bool
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DependencyInjection/service_descriptor.rs#L243)

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

### dependencies

```rust
fn dependencies(self: &Self) -> &[Dependency]
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DependencyInjection/service_descriptor.rs#L246)

## Trait implementations

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

## Availability

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