Skip to main content

Provider

Trait Provider 

Source
pub trait Provider {
    type ProvidedType: 'static;

    // Required method
    fn provide(
        &self,
        container: &Container,
    ) -> Result<Self::ProvidedType, InjectError>;

    // Provided method
    fn id(&self) -> TypeId { ... }
}
Expand description

Value provider.

Required Associated Types§

Source

type ProvidedType: 'static

Required Methods§

Source

fn provide( &self, container: &Container, ) -> Result<Self::ProvidedType, InjectError>

Provides the value using the Container

Provided Methods§

Source

fn id(&self) -> TypeId

Returns the type id of the provided type.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl<T: ?Sized + 'static> Provider for Arc<T>

Source§

type ProvidedType = Arc<T>

Source§

fn provide( &self, container: &Container, ) -> Result<Self::ProvidedType, InjectError>

Implementors§