Expand description
Application Container for Dependency Injection
This module provides Laravel-like service container capabilities:
- Singletons: shared instances across the application
- Factories: new instance per resolution
- Trait bindings: bind interfaces to implementations
- Test faking: swap implementations in tests
- Service Providers: bootstrap services with register/boot lifecycle
§Example
ⓘ
use kit::{App, bind, singleton, service};
// Define a service trait with auto-registration
#[service(RealHttpClient)]
pub trait HttpClient {
async fn get(&self, url: &str) -> Result<String, Error>;
}
// Or register manually using macros
bind!(dyn HttpClient, RealHttpClient::new());
singleton!(CacheService::new());
// Resolve anywhere in your app
let client: Arc<dyn HttpClient> = App::make::<dyn HttpClient>().unwrap();Modules§
- provider
- Service auto-registration for Kit framework
- testing
- Test utilities for the Application Container