pub struct Container { /* private fields */ }
Implementations§
Source§impl Container
impl Container
pub fn builder() -> ContainerBuilder
pub fn get_registry(&self) -> &ServiceRegistry
pub fn get_scope(&self) -> &ServiceScope
pub fn set_registry(&mut self, value: ServiceRegistry)
pub fn set_scope(&mut self, value: ServiceScope)
Source§impl Container
impl Container
Sourcepub fn register<T>(&mut self, service: T) -> Result<(), CoreError>
pub fn register<T>(&mut self, service: T) -> Result<(), CoreError>
Register a service in the container
Sourcepub fn register_singleton<T>(&mut self, service: T) -> Result<(), CoreError>
pub fn register_singleton<T>(&mut self, service: T) -> Result<(), CoreError>
Register a singleton service
Sourcepub fn register_transient<T>(
&mut self,
factory: Box<dyn Fn() -> T + Sync + Send>,
) -> Result<(), CoreError>where
T: Service + 'static,
pub fn register_transient<T>(
&mut self,
factory: Box<dyn Fn() -> T + Sync + Send>,
) -> Result<(), CoreError>where
T: Service + 'static,
Register a transient service
Sourcepub fn try_resolve<T>(&self) -> Option<Arc<T>>
pub fn try_resolve<T>(&self) -> Option<Arc<T>>
Try to resolve a service, returning None if not found
Sourcepub async fn initialize(&mut self) -> Result<(), CoreError>
pub async fn initialize(&mut self) -> Result<(), CoreError>
Initialize the container and all its services
Sourcepub fn is_initialized(&self) -> bool
pub fn is_initialized(&self) -> bool
Check if the container is initialized
Sourcepub fn service_count(&self) -> usize
pub fn service_count(&self) -> usize
Get the number of registered services
Sourcepub fn registered_services(&self) -> Vec<TypeId>
pub fn registered_services(&self) -> Vec<TypeId>
Get a list of all registered service types
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Container
impl RefUnwindSafe for Container
impl Send for Container
impl Sync for Container
impl Unpin for Container
impl UnwindSafe for Container
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