rskit-di 0.2.0-alpha.4

Lightweight Arc-based runtime dependency injection container
Documentation

rskit-di — Dependency Injection Container

Lightweight Arc-based runtime dependency injection container.

CI crates.io docs.rs License: MIT MSRV: 1.91

Features

  • Three registration modes: eager (register), lazy factory (register_factory), singleton (register_singleton)
  • Type-keyed resolution via TypeId — no strings, no macros
  • Resolve<T> trait for constructor-oriented workflows
  • Thread-safe with parking_lot::RwLock
  • Closeable trait for async resource cleanup
  • Returns AppResult for idiomatic error handling

Usage

[dependencies]
rskit-di = "0.2.0-alpha.4"
use std::sync::Arc;
use rskit_di::Container;

struct Config { db_url: String }

let container = Container::new();
container.register(Arc::new(Config { db_url: "postgres://...".into() }));

let cfg: Arc<Config> = container.resolve()?;
assert_eq!(cfg.db_url, "postgres://...");
# Ok::<(), rskit_errors::AppError>(())

See Also

Main repository README