Skip to main content

ServiceCollection

Struct ServiceCollection 

Source
pub struct ServiceCollection { /* private fields */ }
Expand description

Ordered registrations; building a provider snapshots this collection.

Implementations§

Source§

impl ServiceCollection

Source

pub fn new() -> Self

Source

pub fn descriptors(&self) -> &[ServiceDescriptor]

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn is_read_only(&self) -> bool

Source

pub fn make_read_only(&mut self)

Source

pub fn add(&mut self, descriptor: ServiceDescriptor) -> &mut Self

Source

pub fn add_sequence( &mut self, descriptors: impl IntoIterator<Item = ServiceDescriptor>, ) -> &mut Self

Source

pub fn insert(&mut self, index: usize, descriptor: ServiceDescriptor)

Source

pub fn remove_at(&mut self, index: usize) -> ServiceDescriptor

Source

pub fn clear(&mut self)

Source

pub fn try_add(&mut self, descriptor: ServiceDescriptor) -> &mut Self

Source

pub fn try_add_enumerable(&mut self, descriptor: ServiceDescriptor) -> &mut Self

Source

pub fn replace(&mut self, descriptor: ServiceDescriptor) -> &mut Self

Removes the first matching registration, then appends the replacement, as upstream.

Source

pub fn remove_all<S: ?Sized + 'static>(&mut self) -> &mut Self

Source

pub fn remove_all_keyed<S: ?Sized + 'static>( &mut self, key: Option<ServiceKey>, ) -> &mut Self

Source

pub fn iter(&self) -> Iter<'_, ServiceDescriptor> ⓘ

Source

pub fn contains(&self, descriptor: &ServiceDescriptor) -> bool

Source

pub fn index_of(&self, descriptor: &ServiceDescriptor) -> Option<usize>

Source

pub fn remove(&mut self, descriptor: &ServiceDescriptor) -> bool

Source

pub fn copy_to(&self, target: &mut [ServiceDescriptor], index: usize)

Source

pub fn build_service_provider( &self, options: ServiceProviderOptions, ) -> ServiceResult<ServiceProvider>

Source

pub fn add_singleton_instance<S: ?Sized + 'static>( &mut self, value: Rc<S>, ) -> &mut Self

Source

pub fn add_keyed_singleton_instance<S: ?Sized + 'static>( &mut self, key: Option<ServiceKey>, value: Rc<S>, ) -> &mut Self

Source§

impl ServiceCollection

Source

pub fn add_singleton<S: ?Sized + 'static, F>(&mut self, factory: F) -> &mut Self
where F: Fn(&ServiceProvider) -> ServiceResult<Rc<S>> + 'static,

Source

pub fn add_keyed_singleton<S: ?Sized + 'static, F>( &mut self, key: Option<ServiceKey>, factory: F, ) -> &mut Self
where F: Fn(&ServiceProvider, Option<&ServiceKey>) -> ServiceResult<Rc<S>> + 'static,

Source§

impl ServiceCollection

Source

pub fn add_scoped<S: ?Sized + 'static, F>(&mut self, factory: F) -> &mut Self
where F: Fn(&ServiceProvider) -> ServiceResult<Rc<S>> + 'static,

Source

pub fn add_keyed_scoped<S: ?Sized + 'static, F>( &mut self, key: Option<ServiceKey>, factory: F, ) -> &mut Self
where F: Fn(&ServiceProvider, Option<&ServiceKey>) -> ServiceResult<Rc<S>> + 'static,

Source§

impl ServiceCollection

Source

pub fn add_transient<S: ?Sized + 'static, F>(&mut self, factory: F) -> &mut Self
where F: Fn(&ServiceProvider) -> ServiceResult<Rc<S>> + 'static,

Source

pub fn add_keyed_transient<S: ?Sized + 'static, F>( &mut self, key: Option<ServiceKey>, factory: F, ) -> &mut Self
where F: Fn(&ServiceProvider, Option<&ServiceKey>) -> ServiceResult<Rc<S>> + 'static,

Trait Implementations§

Source§

impl Clone for ServiceCollection

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for ServiceCollection

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl IServiceCollection for ServiceCollection

Source§

fn descriptors(&self) -> &[ServiceDescriptor]

Source§

fn add(&mut self, descriptor: ServiceDescriptor) -> &mut Self

Source§

impl IServiceProviderFactory<ServiceCollection> for DefaultServiceProviderFactory

Source§

impl Index<usize> for ServiceCollection

Source§

type Output = ServiceDescriptor

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl IndexMut<usize> for ServiceCollection

Source§

fn index_mut(&mut self, index: usize) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<'a> IntoIterator for &'a ServiceCollection

Source§

type Item = &'a ServiceDescriptor

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a, ServiceDescriptor>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.