pub struct DependencyContainer { /* private fields */ }Expand description
A container for managing dependencies and their builders.
It support two types of registrations:
Providers:
Providers are pre-created objects that you want to register directly into the container. For example, you might have a database connection or external service client that you need to build beforehand and inject into other Dependencies.
Components
Are types that has no need to be pre-created. Instead, you register the type itself,
and the container will use the Component trait to build them when needed, resolving
their dependencies automatically.
Implementations§
Source§impl DependencyContainer
impl DependencyContainer
pub fn new() -> Self
pub fn provider_registry(&self) -> &ProviderRegistry
pub fn component_registry(&self) -> &ComponentRegistry
Sourcepub fn build_all(&self, state: &State) -> Result<(), DIError>
pub fn build_all(&self, state: &State) -> Result<(), DIError>
Builds all registered components in dependency order.
This internal method performs the following steps:
- Registers all provider instances in the State
- Performs topological sorting on the dependency graph
- Constructs components recursively in the correct order
- Detects circular dependencies and returns an error if found
This method is called internally during application initialization.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for DependencyContainer
impl !RefUnwindSafe for DependencyContainer
impl !Send for DependencyContainer
impl !Sync for DependencyContainer
impl !UnwindSafe for DependencyContainer
impl Unpin for DependencyContainer
impl UnsafeUnpin for DependencyContainer
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