tanzim-load
Package | Documentation | Repository
First stage of the tanzim pipeline: reads raw configuration bytes from a declared source.
The Load trait
Implement [Load] to add a new source kind (protocol, service, database, …). It only fetches
bytes — parsing happens in a later stage. The contract:
- Return one [
Payload] per config entry found; a single source may expand to many entries. Finding nothing isOk(vec![]), not an error. - Set
Payload::sourceon each entry to the concrete resource loaded (narrow the incoming source withSource::with_resource) so diagnostics stay precise. Payload::maybe_nameis the entry name (Nonemerges into the root);Payload::maybe_formatis a parser hint (e.g.json).- Read options off the source with
Source::options()and the typedOptionValueaccessors, and pick the [Error] variant that matches the failure (InvalidResource,InvalidOption,NotFound,NoAccess,Timeout,Duplicate,Load).
Register a loader with tanzim::Config::with_loader; it's dispatched by the source strings its
supported_source_list() returns. For a quick, stateless adapter, use closure::Closure instead
of a full impl Load. See the [Load] rustdoc and the custom_loader
example for worked details.
Built-in loaders
| Module | Feature | Source string |
|---|---|---|
env |
env |
env |
file |
file |
file |
http |
http |
http |
closure |
— | any (user-defined) |
Example
use env;
use ;
Features
| Feature | Enables |
|---|---|
env |
env loader (reads environment variables) |
file |
file loader (reads from filesystem) |
http |
http loader (user-provided fetch closure) |
logging |
emit log messages via the log crate |
tracing |
emit trace spans via the tracing crate |
full |
env + file + http |
Default features: env, file, http. Logging/tracing are opt-in.
Relations
- Depends on
tanzim-sourceforSourceandOptions. - Produces
Payloadvalues consumed bytanzim-parse. - Full pipeline wired in
tanzim.