Struct di::ScopedServiceProvider
source · pub struct ScopedServiceProvider { /* private fields */ }Expand description
Represents a scoped ServiceProvider.
Remarks
This struct has the exact same functionality as ServiceProvider.
When a new instance is created, it also creates a new scope from the source
ServiceProvider. The primary use case for this struct is to
explicitly declare that a new scope should be created at the injection call site.
Methods from Deref<Target = ServiceProvider>§
sourcepub fn get_mut<T: Any + ?Sized>(&self) -> Option<RefMut<T>>
pub fn get_mut<T: Any + ?Sized>(&self) -> Option<RefMut<T>>
Gets a mutable service of the specified type.
sourcepub fn get_by_key<TKey, TSvc: Any + ?Sized>(
&self
) -> Option<KeyedRef<TKey, TSvc>>
pub fn get_by_key<TKey, TSvc: Any + ?Sized>( &self ) -> Option<KeyedRef<TKey, TSvc>>
Gets a keyed service of the specified type.
sourcepub fn get_by_key_mut<TKey, TSvc: Any + ?Sized>(
&self
) -> Option<KeyedRefMut<TKey, TSvc>>
pub fn get_by_key_mut<TKey, TSvc: Any + ?Sized>( &self ) -> Option<KeyedRefMut<TKey, TSvc>>
Gets a keyed, mutable service of the specified type.
sourcepub fn get_all<T: Any + ?Sized>(&self) -> impl Iterator<Item = Ref<T>> + '_
pub fn get_all<T: Any + ?Sized>(&self) -> impl Iterator<Item = Ref<T>> + '_
Gets all of the services of the specified type.
sourcepub fn get_all_mut<T: Any + ?Sized>(
&self
) -> impl Iterator<Item = RefMut<T>> + '_
pub fn get_all_mut<T: Any + ?Sized>( &self ) -> impl Iterator<Item = RefMut<T>> + '_
Gets all of the mutable services of the specified type.
sourcepub fn get_all_by_key<'a, TKey: 'a, TSvc>(
&'a self
) -> impl Iterator<Item = KeyedRef<TKey, TSvc>> + '_
pub fn get_all_by_key<'a, TKey: 'a, TSvc>( &'a self ) -> impl Iterator<Item = KeyedRef<TKey, TSvc>> + '_
Gets all of the services of the specified key and type.
sourcepub fn get_all_by_key_mut<'a, TKey: 'a, TSvc>(
&'a self
) -> impl Iterator<Item = KeyedRefMut<TKey, TSvc>> + '_
pub fn get_all_by_key_mut<'a, TKey: 'a, TSvc>( &'a self ) -> impl Iterator<Item = KeyedRefMut<TKey, TSvc>> + '_
Gets all of the mutable services of the specified key and type.
sourcepub fn get_required<T: Any + ?Sized>(&self) -> Ref<T>
pub fn get_required<T: Any + ?Sized>(&self) -> Ref<T>
Gets a required service of the specified type.
Panics
The requested service of type T does not exist.
sourcepub fn get_required_mut<T: Any + ?Sized>(&self) -> RefMut<T>
pub fn get_required_mut<T: Any + ?Sized>(&self) -> RefMut<T>
Gets a required, mutable service of the specified type.
Panics
The requested service of type T does not exist.
sourcepub fn get_required_by_key<TKey, TSvc: Any + ?Sized>(
&self
) -> KeyedRef<TKey, TSvc>
pub fn get_required_by_key<TKey, TSvc: Any + ?Sized>( &self ) -> KeyedRef<TKey, TSvc>
Gets a required keyed service of the specified type.
Panics
The requested service of type TSvc with key TKey does not exist.
sourcepub fn get_required_by_key_mut<TKey, TSvc: Any + ?Sized>(
&self
) -> KeyedRefMut<TKey, TSvc>
pub fn get_required_by_key_mut<TKey, TSvc: Any + ?Sized>( &self ) -> KeyedRefMut<TKey, TSvc>
Gets a required keyed service of the specified type.
Panics
The requested service of type TSvc with key TKey does not exist.
sourcepub fn create_scope(&self) -> Self
pub fn create_scope(&self) -> Self
Creates and returns a new service provider that is used to resolve services from a newly create scope.
Trait Implementations§
source§impl AsRef<ServiceProvider> for ScopedServiceProvider
impl AsRef<ServiceProvider> for ScopedServiceProvider
source§fn as_ref(&self) -> &ServiceProvider
fn as_ref(&self) -> &ServiceProvider
source§impl Borrow<ServiceProvider> for ScopedServiceProvider
impl Borrow<ServiceProvider> for ScopedServiceProvider
source§fn borrow(&self) -> &ServiceProvider
fn borrow(&self) -> &ServiceProvider
source§impl Clone for ScopedServiceProvider
impl Clone for ScopedServiceProvider
source§fn clone(&self) -> ScopedServiceProvider
fn clone(&self) -> ScopedServiceProvider
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more