Crate ferrunix

Source
Expand description
§You’re viewing the documentation with no features turned on.

§Ferrunix

A simple, idiomatic, and lightweight dependency injection framework for Rust.

For a comprehensive introduction check out the user guide.

§Documentation

Due to how the various features affect the public API of the library, the documentation is provided seperately for each major feature.

Documentation on docs.rs is compiled with the multithread feature turned on

Feature FlagsLink to Documentation
nonelink to docs
multithreadlink to docs
tokiolink to docs

§Getting Started

The easiest way to get started is with the multi-threaded registry, and the derive macro, you can enable this as follows:

[dependencies]
ferrunix = { version = "0.5", features = ["multithread"] }

§Cargo Feature Flags

Ferrunix has the following features to enable further functionality. Features enabled by default are marked with *.

  • multithread: Enables support for accessing the registry from multiple threads. This adds a bound that all registered types must be Send.
  • derive (*): Enables support for the #[derive(Inject)] macro.
  • tokio: Enables support for async constructors. Bumps the MSRV up to 1.75.0 because some of the internal traits require RPITIT.
  • tracing: Enables support for tracing and annotates all public functions with tracing::instrument.

Modules§

dependencies
All possible dependencies for injected types.
dependency_builder
Implementation of DepBuilder for tuples to be used with Registry::with_deps.
error
All errors that might happen.
registry
Holds all registered types that can be injected or constructed.
types
Type aliases.

Macros§

autoregister
Register a RegistrationFunc. Usually invoked by the derive macro.

Structs§

RegistrationFunc
All auto-registration functions need to use this type for registration.
Registry
Registry for all types that can be constructed or otherwise injected.
Singleton
Singleton dependencies.
Transient
Transient dependencies.

Type Aliases§

Ref
A generic reference type that’s used as the default type for types with the singleton lifetime.

Derive Macros§

Inject
#[derive(Inject)] proc-macro for ferrunix.