Noema
Rust toolkit for Dependency Injection (DI) and Inversion of Control (IoC).
Compile-time registration, thread-safe resolution via Arc<T>, extensible with Mediator, Events, and more.
DI macro guide:
docs/di.md— exact syntax, examples, and rules.
Quick start (DI)
use ;
use ;
;
dependency!;
dependency_as!;
let cfg = ;
let g = ;
Registration macros (quick reference)
| Macro | Purpose |
|---|---|
dependency!(lifecycle, Type) |
Concrete type; lifecycle = singleton or transient |
dependency_as!(lifecycle, Trait: Impl) |
Trait binding |
dependency_as_many!(Trait: [(lifecycle, Impl), …]) |
Batch of impls; lifecycle per entry |
dependency_keyed_as!(K, Trait: [(key, lifecycle, Impl), …]) |
Keyed batch; lifecycle per entry |
Trait syntax in _as macros: Logger: MyImpl (expands to dyn Logger + Send + Sync)
Resolution: resolve::<T>(), resolve::<Arc<[Arc<T>]>>(), resolve::<Keyed<&str, S>>()
Full details → docs/di.md.
Features
| Feature | Default | Description |
|---|---|---|
di |
✓ | DI: macros + resolve() |
mediator |
Mediator (Input / Handler / send) |
|
events |
Typed events (JSON wire, user transports) | |
items_collections |
Extensible enum-like collections (items! / ItemSet) |
|
configurations |
Typed config (config! / load(source)) |
|
full |
All of the above |
[]
= { = "0.3", = ["di", "mediator"] }
Guides: docs/di.md, docs/events.md, docs/items.md, docs/config.md.
Design
Container— ZST marker; no runtime state in v1- Single /
_as— one binding per macro; duplicate → compile error - Many / keyed — one batch per call; crates merge at resolve (see
noema-integration/) - Concurrency —
Arc<T>+LazyLockfor singletons
License
MIT OR Apache-2.0