Expand description
Concrete dependency injection built from plain structs and function pointers.
clients models each dependency as a concrete, cloneable value type instead of a
trait object. The usual flow is:
- declare a dependency client with
client! - resolve dependency methods in free functions with
deps! - override methods in tests with
test_deps! - inject whole dependency values into structs via
Depends
The design intentionally favors low ceremony. Live implementations are plain non-capturing closures or function items, and test overrides swap those same function pointers in scoped layers.
Modules§
- clock
- Dependency client for wall-clock time and coarse sleeping.
- env
- Dependency client for basic process-environment access.
- filesystem
- Dependency client for small read and write file operations.
- random
- Dependency client for pseudo-random data.
Macros§
- client
- Declares a concrete dependency client backed by raw function pointers.
- deps
- Binds dependency methods from generated helper modules into local variables.
- test_
deps - Installs one or more dependency overrides for the remainder of the current scope, keeping the test body flat and unindented.
Structs§
- Clock
- Dependency client for wall-clock time and coarse sleeping.
- Env
- Dependency client for basic process-environment access.
- Filesystem
- Dependency client for small read and write file operations.
- Override
Builder - Builds one scoped layer of dependency overrides.
- Override
Guard - RAII guard that keeps an override scope active until dropped.
- Random
- Dependency client for pseudo-random data.
Enums§
- Dependency
Error - Common error type used by dependency-based APIs in examples and hand-written live implementations.
Traits§
- Dependency
- A concrete dependency value that can provide its live implementation.
Functions§
- boxed
- Boxes a future into
BoxFuture. - get
- Resolves the current dependency value for
D. - unimplemented_
dependency - Panics with a consistent message for an unimplemented dependency path.
Type Aliases§
- BoxFuture
- A boxed, sendable future used by async dependency methods.
Derive Macros§
- Depends
- Derives dependency-backed construction for a simple braced struct.