pub struct ContainerBuilder { /* private fields */ }
Expand description
Builder for constructing containers with services
Implementations§
Source§impl ContainerBuilder
impl ContainerBuilder
Sourcepub fn with_scope(self, scope: ServiceScope) -> Self
pub fn with_scope(self, scope: ServiceScope) -> Self
Set the default scope for services
Sourcepub fn add_service<T>(self, service: T) -> Result<Self, CoreError>
pub fn add_service<T>(self, service: T) -> Result<Self, CoreError>
Add a service to the container
Sourcepub fn add_singleton<T>(self, service: T) -> Result<Self, CoreError>
pub fn add_singleton<T>(self, service: T) -> Result<Self, CoreError>
Add a singleton service
Sourcepub fn add_transient<T>(
self,
factory: Box<dyn Fn() -> T + Send + Sync>,
) -> Result<Self, CoreError>where
T: Service + 'static,
pub fn add_transient<T>(
self,
factory: Box<dyn Fn() -> T + Send + Sync>,
) -> Result<Self, CoreError>where
T: Service + 'static,
Add a transient service with factory
Sourcepub fn add_services<T>(self, services: Vec<T>) -> Result<Self, CoreError>
pub fn add_services<T>(self, services: Vec<T>) -> Result<Self, CoreError>
Add multiple services at once
Sourcepub fn configure<F>(self, configure: F) -> Result<Self, CoreError>
pub fn configure<F>(self, configure: F) -> Result<Self, CoreError>
Configure the builder from a configuration closure
Sourcepub async fn build_and_initialize(self) -> Result<Container, CoreError>
pub async fn build_and_initialize(self) -> Result<Container, CoreError>
Build and initialize the container
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ContainerBuilder
impl RefUnwindSafe for ContainerBuilder
impl Send for ContainerBuilder
impl Sync for ContainerBuilder
impl Unpin for ContainerBuilder
impl UnwindSafe for ContainerBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more