pub struct Container { /* private fields */ }Expand description
This is the crate users will import. It re-exports the internal pieces use nestforge::{NestForgeFactory, ModuleDefinition, Container}; 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() -> Container
pub fn new() -> Container
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>
Source§type Rejection = HttpException
type Rejection = HttpException
If the extractor fails it’ll use this “rejection” type. A rejection is
a kind of error that can be converted into a response.
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