Cargo Features
[dependencies]
dependency-injector = { version = "0.2.2", default-features = false, features = ["logging", "logging-pretty", "logging-json", "tracing", "async", "derive", "perfect-hash", "dhat-heap", "ffi"] }
Note: For FFI shared library builds, use:
cargo rustc --release --features ffi --crate-type cdylib
- default = logging
-
The
loggingfeature is set by default wheneverdependency-injectoris added withoutsomewhere in the dependency tree.default-features = false - logging default logging-json? logging-pretty? tracing?
-
Enable debug logging (recommended)
Enables tracing
Structured logging (optional)
Affects
dependency-injector::logging,logging::LoggingBuilder,logging::builder… - logging-pretty = logging
-
Pretty console output (for development)
Enables tracing-subscriber
Log subscriber for formatting (optional)
Affects
logging::init,logging::init_json,logging::init_pretty,logging::init_di_only… - logging-json = logging
-
JSON structured logging (for production)
Enables json of tracing-subscriber
Affects
logging::init,logging::init_json,logging::init_pretty,logging::init_di_only… - tracing = logging
-
Legacy alias
- async
-
Async support
Enables tokio
Optional async support
- derive
-
Derive macros for automatic injection
Enables dependency-injector-derive
Derive macros (optional)
- perfect-hash
-
Perfect hashing for locked containers (~5ns faster resolution)
Enables boomphf
Minimal perfect hashing for locked containers (optional)
Affects
storage::FrozenStorage… - dhat-heap
-
Heap profiling with dhat (for memory leak detection)
Enables dhat
Heap profiler for memory leak detection (optional)
- ffi
-
FFI bindings for C/Go/Python interop
Affects
dependency-injector::ffi…