4 releases
| 0.6.6 | Sep 28, 2025 |
|---|---|
| 0.6.4 | Sep 5, 2025 |
| 0.6.3 | Aug 1, 2025 |
| 0.6.2 | Aug 1, 2025 |
#548 in WebSocket
135 downloads per month
Used in 2 crates
(via volga)
27KB
512 lines
Volga DI
A standalone, flexible, and easy-to-configure DI container.
💡 Note: This project is currently in preview. Breaking changes can be introduced without prior notice.
Getting Started
Dependencies
Standalone
[dependencies]
volga-di = "0.6.6"
Part of Volga Web Framework
[dependencies]
volga = { version = "0.6.6", features = ["di"] }
Derive-macro support
[dependencies]
volga = { version = "0.6.6", features = ["di-full"] }
Example
use std::collections::HashMap;
use std::sync::{Arc, Mutex};
#[derive(Default)]
struct InMemoryCache {
inner: Arc<Mutex<HashMap<String, String>>>
}
fn main() {
let mut container = ContainerBuilder::new();
container.register_singleton(InMemoryCache::default());
let container = container.build();
let Ok(cache) = container.resolve::<InMemoryCache>() else {
eprintln!("Unable to resolve InMemoryCache")
};
// Do work...
}
Dependencies
~520–710KB
~12K SLoC