Skip to main content

Provider

Trait Provider 

Source
pub trait Provider<T>: Send + Sync {
    // Required method
    fn provide(&self) -> HexResult<T>;
}
Expand description

Provider for creating service instances

Implementors define how to construct instances of type T, potentially using other services from the container.

Required Methods§

Source

fn provide(&self) -> HexResult<T>

Create new instance of service

Called by container when resolving a service. For Singleton scope, this is called once and cached. For Transient scope, called on every resolution.

§Returns

New instance of the service

§Errors

Returns ContainerError if instance creation fails

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§