Configuration parsing, validation, and lowering primitives for Rust.
Configuration is parsed span-first, so every value carries the byte range it came from and every later check can point at the place in the file that caused it. The core does not depend on any file format. A frontend converts one syntax into a format-neutral field model. Everything after parsing works against that model.
The toml example, hcl example, kdl example, json example, and yaml example demonstrate how this crate is meant to be used. The five run the same steps in the same order. Only the source text, its file name, and the two format calls that parse and emit it differ.
The layering example assembles one configuration from a file, the environment, and the command line.
The templates example writes an annotated configuration file from the spec types (it essentially runs the pipeline backward).
Fourteen examples ship in total. The Examples page lists what each one covers along with its run command.
See the confval documentation for the full API overview.
The confval crate was extracted from the Snakeway reverse proxy configuration subsystem.
- In this repo
- An example PR for mini-redis
- Snakeway reverse proxy's snakeway-conf crate (advanced usage)
confval ships a binary that installs two agent skills into a project: one that scaffolds a pipeline and one that keeps its layers in sync as the configuration grows.
Install the binary with cargo install confval, then run confval init.
See Agent Skills for what each skill does, where the files land, and what the outcomes and exit codes mean.
Apache-2.0