sword_core/injectables/
mod.rs1mod components;
2mod container;
3mod error;
4mod providers;
5
6use crate::State;
7
8use std::{
9 any::{Any, TypeId},
10 sync::Arc,
11};
12
13pub use components::{Component, ComponentRegistry};
14pub use container::DependencyContainer;
15pub use error::DependencyInjectionError;
16pub use providers::{Provider, ProviderRegistry};
17
18pub trait Build: Clone + Send + Sync + 'static {
20 fn build(state: &State) -> Result<Self, DependencyInjectionError>
21 where
22 Self: Sized;
23}
24
25pub trait HasDeps: Build {
30 fn deps() -> Vec<TypeId> {
31 Vec::new()
32 }
33}
34
35pub(crate) type Injectable = Arc<dyn Any + Send + Sync>;