Struct runtime_injector::ConstantProvider[][src]

pub struct ConstantProvider<R> where
    R: Service
{ /* fields omitted */ }
Expand description

A provider which returns a constant, predetermined value. Note that this is technically a singleton service in that it does not recreate the value each time it is requested.

Implementations

impl<R> ConstantProvider<R> where
    R: Service
[src]

#[must_use]
pub fn new(value: R) -> Self
[src]

Creates a new ConstantProvider using a predetermined value.

Trait Implementations

impl<T: Service> From<T> for ConstantProvider<T>[src]

fn from(value: T) -> Self[src]

Performs the conversion.

impl<R> TypedProvider for ConstantProvider<R> where
    R: Service
[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<R> RefUnwindSafe for ConstantProvider<R> where
    R: RefUnwindSafe

impl<R> Send for ConstantProvider<R>

impl<R> Sync for ConstantProvider<R>

impl<R> Unpin for ConstantProvider<R>

impl<R> UnwindSafe for ConstantProvider<R> where
    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.