pub struct IocContainer { /* private fields */ }Expand description
Lightweight IoC container for dependency injection
Implementations§
Source§impl IocContainer
impl IocContainer
pub fn new() -> Self
pub fn register<T: Clone + Any + Send + Sync + 'static>( self, service: T, ) -> Self
Sourcepub fn register_service<T: Clone + Any + Send + Sync + 'static>(
&self,
service: T,
)
pub fn register_service<T: Clone + Any + Send + Sync + 'static>( &self, service: T, )
Register a service from a reference (for late registration after construction)
pub fn clear(&self)
pub fn resolve<T: Clone + Any + Send + Sync + 'static>(&self) -> Result<T>
Trait Implementations§
Source§impl Clone for IocContainer
impl Clone for IocContainer
Auto Trait Implementations§
impl Freeze for IocContainer
impl RefUnwindSafe for IocContainer
impl Send for IocContainer
impl Sync for IocContainer
impl Unpin for IocContainer
impl UnsafeUnpin for IocContainer
impl UnwindSafe for IocContainer
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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