pub struct ServiceCollection { /* private fields */ }Expand description
Represents a service collection.
Implementations§
Source§impl ServiceCollection
impl ServiceCollection
Sourcepub fn remove(&mut self, index: usize) -> ServiceDescriptor
pub fn remove(&mut self, index: usize) -> ServiceDescriptor
Sourcepub fn add<T: Into<ServiceDescriptor>>(&mut self, descriptor: T) -> &mut Self
pub fn add<T: Into<ServiceDescriptor>>(&mut self, descriptor: T) -> &mut Self
Adds a service using the specified service descriptor.
§Arguments
descriptor- TheServiceDescriptorto register
Sourcepub fn try_add<T: Into<ServiceDescriptor>>(
&mut self,
descriptor: T,
) -> &mut Self
pub fn try_add<T: Into<ServiceDescriptor>>( &mut self, descriptor: T, ) -> &mut Self
Adds a service using the specified service descriptor if the service has not already been registered.
§Arguments
descriptor- TheServiceDescriptorto register
Sourcepub fn try_add_to_all<T: Into<ServiceDescriptor>>(
&mut self,
descriptor: T,
) -> &mut Self
pub fn try_add_to_all<T: Into<ServiceDescriptor>>( &mut self, descriptor: T, ) -> &mut Self
Adds a service using the specified service descriptor if the service with same service and implementation type has not already been registered.
§Arguments
descriptor- TheServiceDescriptorto register
Sourcepub fn try_add_all(
&mut self,
descriptors: impl IntoIterator<Item = ServiceDescriptor>,
) -> &mut Self
pub fn try_add_all( &mut self, descriptors: impl IntoIterator<Item = ServiceDescriptor>, ) -> &mut Self
Adds the specified service descriptors if each of the services are not already registered with the same service and implementation type.
§Arguments
descriptors- TheServiceDescriptorsequence to register
Sourcepub fn replace<T: Into<ServiceDescriptor>>(
&mut self,
descriptor: T,
) -> &mut Self
pub fn replace<T: Into<ServiceDescriptor>>( &mut self, descriptor: T, ) -> &mut Self
Removes the first service descriptor with the same service type and adds the replacement.
§Arguments
descriptor- The replacementServiceDescriptor
Sourcepub fn try_replace<T: Into<ServiceDescriptor>>(
&mut self,
descriptor: T,
) -> &mut Self
pub fn try_replace<T: Into<ServiceDescriptor>>( &mut self, descriptor: T, ) -> &mut Self
Adds or replaces a service with the specified descriptor if the service has not already been registered.
§Arguments
descriptor- The replacementServiceDescriptor
Sourcepub fn remove_all<T: Any + ?Sized>(&mut self) -> &mut Self
pub fn remove_all<T: Any + ?Sized>(&mut self) -> &mut Self
Removes all specified descriptors of the specified type.
Sourcepub fn build_provider(&self) -> Result<ServiceProvider, ValidationError>
pub fn build_provider(&self) -> Result<ServiceProvider, ValidationError>
Builds and returns a new ServiceProvider.
Sourcepub fn iter(
&self,
) -> impl Iterator<Item = &ServiceDescriptor> + ExactSizeIterator + DoubleEndedIterator
pub fn iter( &self, ) -> impl Iterator<Item = &ServiceDescriptor> + ExactSizeIterator + DoubleEndedIterator
Gets a read-only iterator for the collection
Trait Implementations§
Source§impl Debug for ServiceCollection
impl Debug for ServiceCollection
Source§impl Default for ServiceCollection
impl Default for ServiceCollection
Source§fn default() -> ServiceCollection
fn default() -> ServiceCollection
Source§impl Display for ServiceCollection
Available on crate feature fmt only.
impl Display for ServiceCollection
fmt only.