auto-di
Spring-style dependency injection for Rust, backed by a global inventory
registry and async-safe initialization.
Components and constructor injection
use Arc;
use ;
#[component], #[service], #[repository], and #[singleton] share these
options:
name = "..."primaryscope = "singleton" | "prototype" | "request"eagerprofile = "development"condition = "ENV_KEY"orcondition = "ENV_KEY=value"post_construct = "async_method"pre_destroy = "async_method"
Constructors accept Arc<T>, Option<Arc<T>>, Vec<Arc<T>>, Provider<T>,
and Lazy<T>. Both sync and async constructors are supported.
Configuration beans
;
Environment properties
Application and request scopes
async
let request = global_container?.request_context;
let bean = request..await?;
Active profiles come from comma-separated APP_PROFILES, or can be selected
explicitly with Container::with_profiles(...).