fundle 0.2.0

Compile-time safe dependency injection for Rust.
Documentation

Fundle

crate.io docs.rs MSRV CI Coverage License

Summary

Compile-time safe dependency injection for Rust.

Fundle is a dependency injection system for service libraries. Library authors can simply declare their dependencies, and applications will not compile unless all dependencies are initialized, without application authors having to pass them one-by-one.

Capabilities

  • Type-safe builder pattern - Each field must be set exactly once before building
  • Dependency injection - Fields can access previously set fields during construction
  • Automatic AsRef implementations - Generated for unique field types
  • Multiple setter variants - Regular, try (fallible), async, and async-try setters

Quick Start

#[fundle::bundle]
pub struct AppState {
    logger: Logger,
    database: Database,
    config: Config,
}

fn main() {
    let app = AppState::builder()
        .logger(|_| Logger::new())
        .config(|x| Config::new_with_logger(x))
        .database(|x| Database::connect("postgresql://localhost", x))
        .build();
}

This crate was developed as part of The Oxidizer Project.