pub struct Container { /* private fields */ }Expand description
Thread-safe provider container with shared singleton and isolated request caches.
Implementations§
Source§impl Container
impl Container
Sourcepub fn builder() -> ContainerBuilder
pub fn builder() -> ContainerBuilder
Start constructing and validating a dependency container.
Sourcepub fn resolve<T: Send + Sync + 'static>(&self) -> Result<Arc<T>, InjectError>
pub fn resolve<T: Send + Sync + 'static>(&self) -> Result<Arc<T>, InjectError>
Resolve a provider; request providers require a request context.
Sourcepub fn resolve_optional<T: Send + Sync + 'static>(
&self,
) -> Result<Option<Arc<T>>, InjectError>
pub fn resolve_optional<T: Send + Sync + 'static>( &self, ) -> Result<Option<Arc<T>>, InjectError>
Return None only for an unregistered optional provider; propagate factory failures.
Sourcepub fn request(&self) -> RequestScope
pub fn request(&self) -> RequestScope
Start an independent request cache while sharing application singletons.
Sourcepub fn initialize(&self) -> Result<(), InjectError>
pub fn initialize(&self) -> Result<(), InjectError>
Eagerly construct singletons so factory failures are reported before listening. Request and transient factories are constructed only when resolved.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Container
impl !UnwindSafe for Container
impl Freeze for Container
impl Send for Container
impl Sync for Container
impl Unpin for Container
impl UnsafeUnpin 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