Skip to main content

Crate clients

Crate clients 

Source
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.
OverrideBuilder
Builds one scoped layer of dependency overrides.
OverrideGuard
RAII guard that keeps an override scope active until dropped.
Random
Dependency client for pseudo-random data.

Enums§

DependencyError
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.