Injectium – a minimal dependency-injection implementation for Rust.
This is the user-facing crate that re-exports everything from
injectium_core and adds the
#[derive(Injectable)] proc-macro.
Quick Start
use ;
// Define services that need DI
// At startup, build the container
let c = container! ;
// Validate everything is wired up
c.validate;
// Later, resolve services
let svc = from_container;
Key Types
- [
Container] – the runtime container holding singletons and factories. - [
ContainerBuilder] – fluent builder for constructing a container. - [
Injectable] – trait for types that can construct themselves from a container. Implement via#[derive(Injectable)]. - [
container] – macro for building a container with singletons and factories. - [
declare_dependency!] – manually declare a type is required (usually automatic via#[derive(Injectable)]).