Struct runtime_injector_actix::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]
impl<R> ConstantProvider<R> where
R: Service,
[src]#[must_use]pub fn new(value: R) -> ConstantProvider<R>
[src]
#[must_use]pub fn new(value: R) -> ConstantProvider<R>
[src]Creates a new ConstantProvider
using a predetermined value.
Trait Implementations
impl<T> From<T> for ConstantProvider<T> where
T: Service,
[src]
impl<T> From<T> for ConstantProvider<T> where
T: Service,
[src]pub fn from(value: T) -> ConstantProvider<T>
[src]
pub fn from(value: T) -> ConstantProvider<T>
[src]Performs the conversion.
impl<R> TypedProvider for ConstantProvider<R> where
R: Service,
[src]
impl<R> TypedProvider for ConstantProvider<R> where
R: Service,
[src]type Result = R
type Result = R
The type of service this can provide.
pub fn provide_typed(
&mut self,
_injector: &Injector,
_request_info: &RequestInfo
) -> Result<Arc<<ConstantProvider<R> as TypedProvider>::Result>, InjectError>
[src]
pub fn provide_typed(
&mut self,
_injector: &Injector,
_request_info: &RequestInfo
) -> Result<Arc<<ConstantProvider<R> as TypedProvider>::Result>, InjectError>
[src]fn provide_owned_typed(
&mut self,
_injector: &Injector,
_request_info: &RequestInfo
) -> Result<Box<Self::Result, Global>, InjectError>
[src]
fn provide_owned_typed(
&mut self,
_injector: &Injector,
_request_info: &RequestInfo
) -> Result<Box<Self::Result, Global>, InjectError>
[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>(self) -> InterfaceProvider<I, Self> where
I: InterfaceFor<Self::Result> + ?Sized,
[src]
fn with_interface<I>(self) -> InterfaceProvider<I, Self> where
I: InterfaceFor<Self::Result> + ?Sized,
[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,
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,
R: RefUnwindSafe,
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> Instrument for T
[src]
impl<T> Instrument for T
[src]fn instrument(self, span: Span) -> Instrumented<Self>
[src]
fn instrument(self, span: Span) -> Instrumented<Self>
[src]Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
fn in_current_span(self) -> Instrumented<Self>
[src]
fn in_current_span(self) -> Instrumented<Self>
[src]impl<T> Instrument for T
[src]
impl<T> Instrument for T
[src]fn instrument(self, span: Span) -> Instrumented<Self>
[src]
fn instrument(self, span: Span) -> Instrumented<Self>
[src]Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
fn in_current_span(self) -> Instrumented<Self>
[src]
fn in_current_span(self) -> Instrumented<Self>
[src]impl<T> Interface for T where
T: Service,
[src]
impl<T> Interface for T where
T: Service,
[src]impl<T> Provider for T where
T: TypedProvider,
[src]
impl<T> Provider for T where
T: TypedProvider,
[src]pub fn result(&self) -> ServiceInfo
[src]
pub fn result(&self) -> ServiceInfo
[src]The ServiceInfo
which describes the type returned by this provider.
pub fn provide(
&mut self,
injector: &Injector,
request_info: &RequestInfo
) -> Result<Arc<dyn Any + 'static + Sync + Send>, InjectError>
[src]
pub fn provide(
&mut self,
injector: &Injector,
request_info: &RequestInfo
) -> Result<Arc<dyn Any + 'static + Sync + Send>, InjectError>
[src]Provides an instance of the service.
pub fn provide_owned(
&mut self,
injector: &Injector,
request_info: &RequestInfo
) -> Result<Box<dyn Any + 'static + Sync + Send, Global>, InjectError>
[src]
pub fn provide_owned(
&mut self,
injector: &Injector,
request_info: &RequestInfo
) -> Result<Box<dyn Any + 'static + Sync + Send, Global>, InjectError>
[src]Provides an owned instance of the service.
impl<T> Same<T> for T
impl<T> Same<T> for T
type Output = T
type Output = T
Should always be Self
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
pub fn vzip(self) -> V
impl<P> WithCondition for P where
P: TypedProvider,
[src]
impl<P> WithCondition for P where
P: TypedProvider,
[src]pub fn with_condition<F>(self, condition: F) -> ConditionalProvider<P, F> where
F: Service + Fn(&Injector, &RequestInfo) -> bool,
[src]
pub fn with_condition<F>(self, condition: F) -> ConditionalProvider<P, F> where
F: Service + Fn(&Injector, &RequestInfo) -> bool,
[src]Creates a conditional provider. Conditional providers create their values only if their condition is met. If the condition is not met, then the provider is skipped. Read more
impl<T> InterfaceFor<T> for T where
T: Service,
[src]
T: Service,
impl<T> Service for T where
T: Any + Send + Sync + ?Sized,
[src]
T: Any + Send + Sync + ?Sized,