pub struct ServiceDescriptor {
pub service_key: ServiceKey,
pub lifetime: Lifetime,
pub factory: Arc<ServiceFactory>,
pub service_type: TypeId,
pub implementation_type: TypeId,
}Expand description
Service descriptor - describes how to create and manage service instances
Fields§
§service_key: ServiceKeyService key for uniquely identifying services
lifetime: LifetimeService lifetime
factory: Arc<ServiceFactory>Service factory function for creating service instances
service_type: TypeIdService type ID
implementation_type: TypeIdImplementation type ID (may differ from service type)
Implementations§
Source§impl ServiceDescriptor
impl ServiceDescriptor
Sourcepub fn new<TService, TImplementation>(
service_key: ServiceKey,
lifetime: Lifetime,
factory: ServiceFactory,
) -> Selfwhere
TService: 'static,
TImplementation: 'static,
pub fn new<TService, TImplementation>(
service_key: ServiceKey,
lifetime: Lifetime,
factory: ServiceFactory,
) -> Selfwhere
TService: 'static,
TImplementation: 'static,
Create a new service descriptor
Sourcepub fn transient<TService, TImplementation>(factory: ServiceFactory) -> Selfwhere
TService: 'static,
TImplementation: 'static,
pub fn transient<TService, TImplementation>(factory: ServiceFactory) -> Selfwhere
TService: 'static,
TImplementation: 'static,
Create a type-based transient service descriptor
Sourcepub fn scoped<TService, TImplementation>(factory: ServiceFactory) -> Selfwhere
TService: 'static,
TImplementation: 'static,
pub fn scoped<TService, TImplementation>(factory: ServiceFactory) -> Selfwhere
TService: 'static,
TImplementation: 'static,
Create a type-based scoped service descriptor
Sourcepub fn singleton<TService, TImplementation>(factory: ServiceFactory) -> Selfwhere
TService: 'static,
TImplementation: 'static,
pub fn singleton<TService, TImplementation>(factory: ServiceFactory) -> Selfwhere
TService: 'static,
TImplementation: 'static,
Create a type-based singleton service descriptor
Sourcepub fn named_transient<TService, TImplementation>(
name: impl Into<String>,
factory: ServiceFactory,
) -> Selfwhere
TService: 'static,
TImplementation: 'static,
pub fn named_transient<TService, TImplementation>(
name: impl Into<String>,
factory: ServiceFactory,
) -> Selfwhere
TService: 'static,
TImplementation: 'static,
Create a name-based transient service descriptor
Sourcepub fn named_scoped<TService, TImplementation>(
name: impl Into<String>,
factory: ServiceFactory,
) -> Selfwhere
TService: 'static,
TImplementation: 'static,
pub fn named_scoped<TService, TImplementation>(
name: impl Into<String>,
factory: ServiceFactory,
) -> Selfwhere
TService: 'static,
TImplementation: 'static,
Create a name-based scoped service descriptor
Sourcepub fn named_singleton<TService, TImplementation>(
name: impl Into<String>,
factory: ServiceFactory,
) -> Selfwhere
TService: 'static,
TImplementation: 'static,
pub fn named_singleton<TService, TImplementation>(
name: impl Into<String>,
factory: ServiceFactory,
) -> Selfwhere
TService: 'static,
TImplementation: 'static,
Create a name-based singleton service descriptor
Sourcepub fn from_instance<TService>(instance: TService) -> Self
pub fn from_instance<TService>(instance: TService) -> Self
Create a singleton service descriptor from an instance
Sourcepub fn from_named_instance<TService>(
name: impl Into<String>,
instance: TService,
) -> Self
pub fn from_named_instance<TService>( name: impl Into<String>, instance: TService, ) -> Self
Create a singleton service descriptor from a named instance
Sourcepub fn matches_key(&self, key: &ServiceKey) -> bool
pub fn matches_key(&self, key: &ServiceKey) -> bool
Check if the service key matches
Sourcepub fn matches_service_type<T: 'static>(&self) -> bool
pub fn matches_service_type<T: 'static>(&self) -> bool
Check if the service type matches
Sourcepub fn create_instance(
&self,
provider: &dyn ServiceProvider,
) -> DiResult<Box<dyn Any + Send + Sync>>
pub fn create_instance( &self, provider: &dyn ServiceProvider, ) -> DiResult<Box<dyn Any + Send + Sync>>
Create a service instance
Trait Implementations§
Source§impl Clone for ServiceDescriptor
impl Clone for ServiceDescriptor
Source§fn clone(&self) -> ServiceDescriptor
fn clone(&self) -> ServiceDescriptor
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ServiceDescriptor
impl !RefUnwindSafe for ServiceDescriptor
impl Send for ServiceDescriptor
impl Sync for ServiceDescriptor
impl Unpin for ServiceDescriptor
impl !UnwindSafe for ServiceDescriptor
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)