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]
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]
#[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]
impl<D, R, F> From<F> for SingletonProvider<D, R, F> where
R: Service,
F: ServiceFactory<D, Result = R>,
[src]impl<D, R, F> TypedProvider for SingletonProvider<D, R, F> where
D: Service,
R: Service,
F: ServiceFactory<D, Result = R>,
[src]
impl<D, R, F> TypedProvider for SingletonProvider<D, R, F> where
D: Service,
R: Service,
F: ServiceFactory<D, Result = R>,
[src]type Result = R
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]
fn provide_typed(
&mut self,
injector: &Injector,
request_info: &RequestInfo
) -> InjectResult<Svc<Self::Result>>
[src]fn provide_owned_typed(
&mut self,
_injector: &Injector,
_request_info: &RequestInfo
) -> InjectResult<Box<Self::Result>>
[src]
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]
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,
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,
F: Unpin,
impl<D, R, F> UnwindSafe for SingletonProvider<D, R, F> where
F: UnwindSafe,
R: RefUnwindSafe,
F: UnwindSafe,
R: RefUnwindSafe,