pub struct Container { /* private fields */ }Expand description
Container = our tiny dependency injection store (v1).
What it does:
- stores values by type (TypeId).
- lets us register services/config once.
- lets us resolve them later.
Why Arc?
- so multiple parts of the app can share the same service safely.
Why RwLock?
- allows safe reads/writes across threads.
- write when registering.
- read when resolving.
Implementations§
Source§impl Container
impl Container
Sourcepub fn new() -> Self
pub fn new() -> Self
Nice helper constructor. Same as Default, just cleaner to read in app code.
Trait Implementations§
Source§impl<T> FromRequestParts<Container> for Inject<T>
impl<T> FromRequestParts<Container> for Inject<T>
Auto Trait Implementations§
impl Freeze for Container
impl RefUnwindSafe for Container
impl Send for Container
impl Sync for Container
impl Unpin for Container
impl UnsafeUnpin 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