[dependencies]
ferrunix = "0.3"
Compiler support: requires rustc 1.67.1+
Check out the User Guide.
Documentation
Due to how the various features affect the public API of the library, the documentation is provided for each major feature separately.
Feature Flags | Link to Documentation |
---|---|
none | link to docs |
multithread | link to docs |
tokio | link to docs |
Features
- Can register and inject any type (incl. generics, types must be
Send
if themultithread
feature is enabled, andSend + Sync
iftokio
is enabled). - Simple and elegant Rust API; making the derive macro purely optional.
- Different dependency lifetimes:
- Singleton: Only a single instance of the object is created.
- Transient: A new instance is created for every request.
- Dependency resolution happens at run time, making it possible to dynamically register types.
- Injection of concrete value types (
T
),Box<T>
,Rc<T>
, andArc<T>
. - Derive macro (
#[derive(Inject)]
) to simplify registration. - Automatic registration of types, thanks to
inventory
. - One global registry; with support for multiple sub-registries.
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 beSend
.derive
(*
): Enables support for the#[derive(Inject)]
macro.tokio
: Enables support forasync
constructors. Bumps the MSRV up to1.75.0
because some of the internal traits require RPITIT.tracing
: Enables support for tracing and annotates all public functions withtracing::instrument
.
License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.By contributing to this project (for example, through submitting a pull request) you agree with the individual contributor license agreement. Make sure to read and understand it.