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, which runs the pipeline backward.
Sixteen examples ship in total, fourteen in the confval crate and two runnable language servers in confval-lsp. 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.
The confval-lsp crate is a schema-generic language server core.
It binds to your #[derive(Spec)] root and a format frontend.
serve_multi serves a configuration that spans several document shapes from one process, one binding per shape.
It serves diagnostics, completion, hover, navigation, document symbols, and quick fixes for any of the five formats.
See Language Server for the walkthrough and a runnable example.
- 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