Struct runtime_injector::SingletonProvider[][src]

pub struct SingletonProvider<D, R, F> where
    R: Service,
    F: ServiceFactory<D, Result = R>, 
{ /* fields omitted */ }
Expand description

A service provider that only creates a single instance of the service. The service is created only during its first request. Any subsequent requests return service pointers to the same service.

Implementations

impl<D, R, F> SingletonProvider<D, R, F> where
    R: Service,
    F: ServiceFactory<D, Result = R>, 
[src]

#[must_use]
pub fn new(func: F) -> Self
[src]

Creates a new SingletonProvider using a service factory.

Trait Implementations

impl<D, R, F> From<F> for SingletonProvider<D, R, F> where
    R: Service,
    F: ServiceFactory<D, Result = R>, 
[src]

fn from(func: F) -> Self[src]

Performs the conversion.

impl<D, R, F> TypedProvider for SingletonProvider<D, R, F> where
    D: Service,
    R: Service,
    F: ServiceFactory<D, Result = R>, 
[src]

type Result = R

The type of service this can provide.

fn provide_typed(
    &mut self,
    injector: &Injector,
    request_info: &RequestInfo
) -> InjectResult<Svc<Self::Result>>
[src]

Provides an instance of the service. The Injector passed in can be used to retrieve instances of any dependencies this service has. Read more

fn provide_owned_typed(
    &mut self,
    _injector: &Injector,
    _request_info: &RequestInfo
) -> InjectResult<Box<Self::Result>>
[src]

Provides an owned instance of the service. Not all providers can provide an owned variant of the service. Read more

fn with_interface<I: ?Sized + InterfaceFor<Self::Result>>(
    self
) -> InterfaceProvider<I, Self>
[src]

Provides this service as an implementation of a particular interface. Rather than requesting this service with its concrete type, it can instead be requested by its interface type. Read more

Auto Trait Implementations

impl<D, R, F> RefUnwindSafe for SingletonProvider<D, R, F> where
    F: RefUnwindSafe,
    R: RefUnwindSafe

impl<D, R, F> Send for SingletonProvider<D, R, F>

impl<D, R, F> Sync for SingletonProvider<D, R, F>

impl<D, R, F> Unpin for SingletonProvider<D, R, F> where
    F: Unpin

impl<D, R, F> UnwindSafe for SingletonProvider<D, R, F> where
    F: UnwindSafe,
    R: RefUnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<!> for T[src]

pub fn from(t: !) -> T[src]

Performs the conversion.

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.