pub struct ContainerBuilder { /* private fields */ }Expand description
Container builder - provides a fluent API for service registration
Implementations§
Source§impl ContainerBuilder
impl ContainerBuilder
Sourcepub fn add_transient<TService, TImplementation>(
self,
factory: impl Fn(&dyn ServiceProvider) -> DiResult<TImplementation> + Send + Sync + 'static,
) -> Self
pub fn add_transient<TService, TImplementation>( self, factory: impl Fn(&dyn ServiceProvider) -> DiResult<TImplementation> + Send + Sync + 'static, ) -> Self
Register a transient service
Sourcepub fn add_transient_self<T>(
self,
factory: impl Fn(&dyn ServiceProvider) -> DiResult<T> + Send + Sync + 'static,
) -> Self
pub fn add_transient_self<T>( self, factory: impl Fn(&dyn ServiceProvider) -> DiResult<T> + Send + Sync + 'static, ) -> Self
Register a transient service (self-registration)
Sourcepub fn add_transient_simple<TService, TImplementation>(
self,
factory: impl Fn() -> TImplementation + Send + Sync + 'static,
) -> Self
pub fn add_transient_simple<TService, TImplementation>( self, factory: impl Fn() -> TImplementation + Send + Sync + 'static, ) -> Self
Register a transient service (no dependencies)
Sourcepub fn add_scoped<TService, TImplementation>(
self,
factory: impl Fn(&dyn ServiceProvider) -> DiResult<TImplementation> + Send + Sync + 'static,
) -> Self
pub fn add_scoped<TService, TImplementation>( self, factory: impl Fn(&dyn ServiceProvider) -> DiResult<TImplementation> + Send + Sync + 'static, ) -> Self
Register a scoped service
Sourcepub fn add_scoped_self<T>(
self,
factory: impl Fn(&dyn ServiceProvider) -> DiResult<T> + Send + Sync + 'static,
) -> Self
pub fn add_scoped_self<T>( self, factory: impl Fn(&dyn ServiceProvider) -> DiResult<T> + Send + Sync + 'static, ) -> Self
Register a scoped service (self-registration)
Sourcepub fn add_scoped_simple<TService, TImplementation>(
self,
factory: impl Fn() -> TImplementation + Send + Sync + 'static,
) -> Self
pub fn add_scoped_simple<TService, TImplementation>( self, factory: impl Fn() -> TImplementation + Send + Sync + 'static, ) -> Self
Register a scoped service (no dependencies)
Sourcepub fn add_singleton<TService, TImplementation>(
self,
factory: impl Fn(&dyn ServiceProvider) -> DiResult<TImplementation> + Send + Sync + 'static,
) -> Self
pub fn add_singleton<TService, TImplementation>( self, factory: impl Fn(&dyn ServiceProvider) -> DiResult<TImplementation> + Send + Sync + 'static, ) -> Self
Register a singleton service
Sourcepub fn add_singleton_self<T>(
self,
factory: impl Fn(&dyn ServiceProvider) -> DiResult<T> + Send + Sync + 'static,
) -> Self
pub fn add_singleton_self<T>( self, factory: impl Fn(&dyn ServiceProvider) -> DiResult<T> + Send + Sync + 'static, ) -> Self
Register a singleton service (self-registration)
Sourcepub fn add_singleton_simple<TService, TImplementation>(
self,
factory: impl Fn() -> TImplementation + Send + Sync + 'static,
) -> Self
pub fn add_singleton_simple<TService, TImplementation>( self, factory: impl Fn() -> TImplementation + Send + Sync + 'static, ) -> Self
Register a singleton service (no dependencies)
Sourcepub fn add_instance<T>(self, instance: T) -> Self
pub fn add_instance<T>(self, instance: T) -> Self
Register a singleton instance
Sourcepub fn add_named_transient<TService, TImplementation>(
self,
name: impl Into<String>,
factory: impl Fn(&dyn ServiceProvider) -> DiResult<TImplementation> + Send + Sync + 'static,
) -> Self
pub fn add_named_transient<TService, TImplementation>( self, name: impl Into<String>, factory: impl Fn(&dyn ServiceProvider) -> DiResult<TImplementation> + Send + Sync + 'static, ) -> Self
Register a named transient service
Sourcepub fn add_named_transient_self<T>(
self,
name: impl Into<String>,
factory: impl Fn(&dyn ServiceProvider) -> DiResult<T> + Send + Sync + 'static,
) -> Self
pub fn add_named_transient_self<T>( self, name: impl Into<String>, factory: impl Fn(&dyn ServiceProvider) -> DiResult<T> + Send + Sync + 'static, ) -> Self
Register a named transient service (self-registration)
Sourcepub fn add_named_transient_simple<TService, TImplementation>(
self,
name: impl Into<String>,
factory: impl Fn() -> TImplementation + Send + Sync + 'static,
) -> Self
pub fn add_named_transient_simple<TService, TImplementation>( self, name: impl Into<String>, factory: impl Fn() -> TImplementation + Send + Sync + 'static, ) -> Self
Register a named transient service (no dependencies)
Sourcepub fn add_named_scoped<TService, TImplementation>(
self,
name: impl Into<String>,
factory: impl Fn(&dyn ServiceProvider) -> DiResult<TImplementation> + Send + Sync + 'static,
) -> Self
pub fn add_named_scoped<TService, TImplementation>( self, name: impl Into<String>, factory: impl Fn(&dyn ServiceProvider) -> DiResult<TImplementation> + Send + Sync + 'static, ) -> Self
Register a named scoped service
Sourcepub fn add_named_scoped_self<T>(
self,
name: impl Into<String>,
factory: impl Fn(&dyn ServiceProvider) -> DiResult<T> + Send + Sync + 'static,
) -> Self
pub fn add_named_scoped_self<T>( self, name: impl Into<String>, factory: impl Fn(&dyn ServiceProvider) -> DiResult<T> + Send + Sync + 'static, ) -> Self
Register a named scoped service (self-registration)
Sourcepub fn add_named_scoped_simple<TService, TImplementation>(
self,
name: impl Into<String>,
factory: impl Fn() -> TImplementation + Send + Sync + 'static,
) -> Self
pub fn add_named_scoped_simple<TService, TImplementation>( self, name: impl Into<String>, factory: impl Fn() -> TImplementation + Send + Sync + 'static, ) -> Self
Register a named scoped service (no dependencies)
Sourcepub fn add_named_singleton<TService, TImplementation>(
self,
name: impl Into<String>,
factory: impl Fn(&dyn ServiceProvider) -> DiResult<TImplementation> + Send + Sync + 'static,
) -> Self
pub fn add_named_singleton<TService, TImplementation>( self, name: impl Into<String>, factory: impl Fn(&dyn ServiceProvider) -> DiResult<TImplementation> + Send + Sync + 'static, ) -> Self
Register a named singleton service
Sourcepub fn add_named_singleton_self<T>(
self,
name: impl Into<String>,
factory: impl Fn(&dyn ServiceProvider) -> DiResult<T> + Send + Sync + 'static,
) -> Self
pub fn add_named_singleton_self<T>( self, name: impl Into<String>, factory: impl Fn(&dyn ServiceProvider) -> DiResult<T> + Send + Sync + 'static, ) -> Self
Register a named singleton service (self-registration)
Sourcepub fn add_named_singleton_simple<TService, TImplementation>(
self,
name: impl Into<String>,
factory: impl Fn() -> TImplementation + Send + Sync + 'static,
) -> Self
pub fn add_named_singleton_simple<TService, TImplementation>( self, name: impl Into<String>, factory: impl Fn() -> TImplementation + Send + Sync + 'static, ) -> Self
Register a named singleton service (no dependencies)
Sourcepub fn add_named_instance<T>(self, name: impl Into<String>, instance: T) -> Self
pub fn add_named_instance<T>(self, name: impl Into<String>, instance: T) -> Self
Register a named singleton instance
Sourcepub fn add_transient_with_deps<TService, TImplementation, TDep1>(
self,
factory: impl Fn(Arc<TDep1>) -> TImplementation + Send + Sync + 'static,
) -> Self
pub fn add_transient_with_deps<TService, TImplementation, TDep1>( self, factory: impl Fn(Arc<TDep1>) -> TImplementation + Send + Sync + 'static, ) -> Self
Register a transient service with dependency injection
Sourcepub fn add_transient_with_deps2<TService, TImplementation, TDep1, TDep2>(
self,
factory: impl Fn(Arc<TDep1>, Arc<TDep2>) -> TImplementation + Send + Sync + 'static,
) -> Self
pub fn add_transient_with_deps2<TService, TImplementation, TDep1, TDep2>( self, factory: impl Fn(Arc<TDep1>, Arc<TDep2>) -> TImplementation + Send + Sync + 'static, ) -> Self
Register a transient service with two dependencies
Sourcepub fn add_scoped_with_deps<TService, TImplementation, TDep1>(
self,
factory: impl Fn(Arc<TDep1>) -> TImplementation + Send + Sync + 'static,
) -> Self
pub fn add_scoped_with_deps<TService, TImplementation, TDep1>( self, factory: impl Fn(Arc<TDep1>) -> TImplementation + Send + Sync + 'static, ) -> Self
Register a scoped service with dependency injection
Sourcepub fn add_scoped_with_deps2<TService, TImplementation, TDep1, TDep2>(
self,
factory: impl Fn(Arc<TDep1>, Arc<TDep2>) -> TImplementation + Send + Sync + 'static,
) -> Self
pub fn add_scoped_with_deps2<TService, TImplementation, TDep1, TDep2>( self, factory: impl Fn(Arc<TDep1>, Arc<TDep2>) -> TImplementation + Send + Sync + 'static, ) -> Self
Register a scoped service with two dependencies
Sourcepub fn add_singleton_with_deps<TService, TImplementation, TDep1>(
self,
factory: impl Fn(Arc<TDep1>) -> TImplementation + Send + Sync + 'static,
) -> Self
pub fn add_singleton_with_deps<TService, TImplementation, TDep1>( self, factory: impl Fn(Arc<TDep1>) -> TImplementation + Send + Sync + 'static, ) -> Self
Register a singleton service with dependency injection
Sourcepub fn add_singleton_with_deps2<TService, TImplementation, TDep1, TDep2>(
self,
factory: impl Fn(Arc<TDep1>, Arc<TDep2>) -> TImplementation + Send + Sync + 'static,
) -> Self
pub fn add_singleton_with_deps2<TService, TImplementation, TDep1, TDep2>( self, factory: impl Fn(Arc<TDep1>, Arc<TDep2>) -> TImplementation + Send + Sync + 'static, ) -> Self
Register a singleton service with two dependencies
Sourcepub fn decorate<TService>(
self,
_decorator: impl Fn(&dyn ServiceProvider, Arc<TService>) -> DiResult<TService> + Send + Sync + 'static,
) -> Self
pub fn decorate<TService>( self, _decorator: impl Fn(&dyn ServiceProvider, Arc<TService>) -> DiResult<TService> + Send + Sync + 'static, ) -> Self
Decorator pattern - decorate existing services
Sourcepub fn add_conditional<TService, TImplementation>(
self,
condition: bool,
lifetime: Lifetime,
factory: impl Fn(&dyn ServiceProvider) -> DiResult<TImplementation> + Send + Sync + 'static,
) -> Self
pub fn add_conditional<TService, TImplementation>( self, condition: bool, lifetime: Lifetime, factory: impl Fn(&dyn ServiceProvider) -> DiResult<TImplementation> + Send + Sync + 'static, ) -> Self
Conditional registration - only register service when condition is met
Sourcepub fn add_services(self, services: Vec<ServiceDescriptor>) -> Self
pub fn add_services(self, services: Vec<ServiceDescriptor>) -> Self
Register multiple services at once
Sourcepub fn build(self) -> ServiceProvider
pub fn build(self) -> ServiceProvider
Build the container