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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
//! # injectable — Compile-time Dependency Injection for Rust
//!
//! A compile-time dependency injection framework using extractor-based DI,
//! inspired by Axum's typed extraction model. No `TypeId` in the public
//! API, no runtime reflection, no `HashMap<TypeId, Box<dyn Any>>`.
//!
//! # Core Philosophy
//!
//! Dependencies are resolved through **typed extractors**, not dynamic lookup.
//! Provider chains are generated at compile time. Constructor parameters
//! behave like Axum extractors. Dependency traversal is statically encoded
//! into generated provider implementations.
//!
//! # Types You Own vs. Types You Don't
//!
//! ## Types You Own — `#[injectable]`
//!
//! For types in your own crate, use the derive macro:
//!
//! ```rust,ignore
//! use injectable_rs::{Injectable, Inject, Container};
//!
//! #[injectable]
//! #[derive(Default)]
//! pub struct Database { pool_size: usize }
//!
//! #[injectable]
//! #[derive(Default)]
//! pub struct UserService { db: Arc<Database> }
//! ```
//!
//! ## Types You Don't Own — `DynProvider`
//!
//! For types from third-party crates (`reqwest::Client`, `sqlx::SqlitePool`,
//! etc.), you can't add `#[injectable]`. Instead, register a
//! dynamic provider:
//!
//! ```rust,ignore
//! use injectable_rs::{Container, DynProvider};
//!
//! let container = Container::builder()
//! .register("", DynProvider::new(|| {
//! Ok(reqwest::Client::new())
//! }))
//! .register("", DynProvider::with_ctx(|ctx| async move {
//! let config = ctx.resolve::<AppConfig>().await?;
//! Ok(sqlx::SqlitePool::connect(&config.db_url).await?)
//! }))
//! .build()
//! .await?;
//!
//! // Resolve owned types (static path)
//! let service = container.resolve::<UserService>().await?;
//!
//! // Resolve external types (registry path)
//! let client = container.resolve_external::<reqwest::Client>().await?;
//! ```
// Re-export runtime types
pub use ;
// Re-export graph types
pub use ;
// Re-export proc macros — all surface area is under #[injectable(...)]
pub use bind;
pub use container;
pub use injectable;
// Type-safe scope markers — `#[injectable(scope = Singleton)]` etc.
pub use ;
pub use ;
/// Commonly used items — `use injectable_rs::prelude::*` covers the full public API.