1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//! IoC service container and dependency injection for the rok ecosystem.
//!
//! Provides a runtime type-map DI container, `#[derive(Injectable)]` for
//! auto-wiring structs, and Axum extractors `Inject<T>` and `Bound<T>`.
//!
//! # Quick start
//!
//! ```rust,ignore
//! use std::sync::Arc;
//! use axum::{routing::get, Extension, Router};
//! use rok_container::{Container, Inject};
//!
//! async fn hello(Inject(svc): Inject<GreetService>) -> String {
//! svc.greet()
//! }
//!
//! let container = Arc::new(Container::new());
//! container.singleton(GreetService::new());
//!
//! let app = Router::new()
//! .route("/hello", get(hello))
//! .layer(Extension(Arc::clone(&container)));
//! ```
//!
//! # Features
//!
//! | Feature | Enables |
//! |---|---|
//! | `axum` | [`Inject<T>`] extractor |
//! | `postgres` | [`Bound<T>`] route-model binding (implies `axum`) |
//! | `macros` | `#[derive(Injectable)]` re-export |
pub use Container;
pub use ContainerError;
pub use Inject;
pub use ;
pub use Injectable;