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};
17pub use sword_macros::injectable;
18
19pub trait Build: Clone + Send + Sync + 'static {
21 fn build(state: &State) -> Result<Self, DependencyInjectionError>
22 where
23 Self: Sized;
24}
25
26pub trait HasDeps: Build {
31 fn deps() -> Vec<TypeId> {
32 Vec::new()
33 }
34}
35
36pub type Injectable = Arc<dyn Any + Send + Sync>;