pub enum Provider<'a> {
Scoped(Scoped),
Singleton(Shared<'a>),
}Expand description
Provides a Container value.
Variants§
Scoped(Scoped)
A provider that returns a new value each time is requested.
Singleton(Shared<'a>)
A provider that returns the same value each time is required.
Implementations§
Source§impl<'a> Provider<'a>
impl<'a> Provider<'a>
Sourcepub fn is_singleton(&self) -> bool
pub fn is_singleton(&self) -> bool
Returns true if the provider is a singleton.
Sourcepub fn kind(&self) -> ProviderKind
pub fn kind(&self) -> ProviderKind
Returns the type of this provider.
Sourcepub fn get_scoped<T>(&self) -> Option<T>
pub fn get_scoped<T>(&self) -> Option<T>
Gets a value of the specified type T or None if T is Inject.
Sourcepub fn get_inject<T>(&self, container: &Container<'_>) -> Option<T>where
T: Inject + 'static,
pub fn get_inject<T>(&self, container: &Container<'_>) -> Option<T>where
T: Inject + 'static,
Gets a value of the specified type T or None if T is not Inject.
Sourcepub fn get_singleton<T>(&self) -> Option<Singleton<T>>
pub fn get_singleton<T>(&self) -> Option<Singleton<T>>
Gets the singleton value of the specified type or None
or None if the provider is not a singleton.
pub fn get_singleton_with<T>( &self, container: &Container<'_>, ) -> Option<Singleton<T>>
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Provider<'a>
impl<'a> !RefUnwindSafe for Provider<'a>
impl<'a> Send for Provider<'a>
impl<'a> Sync for Provider<'a>
impl<'a> Unpin for Provider<'a>
impl<'a> !UnwindSafe for Provider<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more