cfgmatic-source
Layered configuration loading for cfgmatic.
cfgmatic-source is the canonical v5 entrypoint for collecting configuration layers before merge explanation and typed deserialization.
Installation
[]
= { = "5", = ["env", "schema"] }
= { = "1", = ["derive"] }
= "1"
Primary types
Loader: load one source or a slice of sources.SourceCoordinator: register heterogeneous sources with explicit priorities.SourceLayer: one parsed layer before merge.LoadReport: canonical result containing layers, merged content, merge report, load stats, and timings.CascadeLoader: Git-likesystem -> global -> local -> worktreelayering.
Canonical multi-source flow
use *;
let defaults = from_json;
let local = from_json;
let mut coordinator = builder
.add_source
.add_source
.build;
let report = coordinator.load_report?;
let explanation = report.merge_report.explain_path.unwrap;
assert_eq!;
assert_eq!;
# Ok::
Precedence contract
- higher priority sources override lower priority sources;
- equal priorities resolve by later registration order;
collect_layers()returns merge application order;- path explanations use JSON Pointer.
Cascading configuration
use *;
let loader = builder
.add_optional_file
.add_optional_file
.add_optional_file
.add_optional_file
.default_format
.build;
let result = loader.load?;
assert_eq!;
# Ok::
This models .gitconfig-style precedence for TOML/JSON/YAML sources. It does not implement Git's INI syntax or includeIf.
Feature flags
| Feature | Description | Default |
|---|---|---|
file |
File source support | Yes |
env |
Environment variable sources | No |
toml |
TOML parsing | Yes |
json |
JSON parsing | Yes |
yaml |
YAML parsing | No |
schema |
Schema-aware merge diagnostics integration | No |
async |
Async wrappers over the shared loader/coordinator | No |
watch |
File watching dependencies | No |