pub struct ContainerBuilder { /* private fields */ }Expand description
Builder for constructing containers with services
Implementations§
Source§impl ContainerBuilder
impl ContainerBuilder
Sourcepub fn new() -> ContainerBuilder
pub fn new() -> ContainerBuilder
Create a new container builder
Sourcepub fn with_scope(self, scope: ServiceScope) -> ContainerBuilder
pub fn with_scope(self, scope: ServiceScope) -> ContainerBuilder
Set the default scope for services
Sourcepub fn add_service<T>(self, service: T) -> Result<ContainerBuilder, CoreError>
pub fn add_service<T>(self, service: T) -> Result<ContainerBuilder, CoreError>
Add a service to the container
Sourcepub fn add_singleton<T>(self, service: T) -> Result<ContainerBuilder, CoreError>
pub fn add_singleton<T>(self, service: T) -> Result<ContainerBuilder, CoreError>
Add a singleton service
Sourcepub fn add_transient<T>(
self,
factory: Box<dyn Fn() -> T + Sync + Send>,
) -> Result<ContainerBuilder, CoreError>where
T: Service + 'static,
pub fn add_transient<T>(
self,
factory: Box<dyn Fn() -> T + Sync + Send>,
) -> Result<ContainerBuilder, CoreError>where
T: Service + 'static,
Add a transient service with factory
Sourcepub fn add_services<T>(
self,
services: Vec<T>,
) -> Result<ContainerBuilder, CoreError>
pub fn add_services<T>( self, services: Vec<T>, ) -> Result<ContainerBuilder, CoreError>
Add multiple services at once
Sourcepub fn configure<F>(self, configure: F) -> Result<ContainerBuilder, CoreError>
pub fn configure<F>(self, configure: F) -> Result<ContainerBuilder, 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§
Source§impl Default for ContainerBuilder
impl Default for ContainerBuilder
Source§fn default() -> ContainerBuilder
fn default() -> ContainerBuilder
Returns the “default value” for a type. Read more
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more