Introduction
English | 中文 | 日本語 | 한국어 | Français | Deutsch | Español | Português | Svenska | Suomi | Nederlands
rust-config-tree provides reusable configuration-tree loading and CLI helpers
for Rust applications that use layered config files.
The crate is designed around a small division of responsibilities:
confiqueowns schema definitions, code defaults, validation, and config template generation.figmentowns runtime loading and runtime source metadata.rust-config-treeowns recursive include traversal, include path resolution,.envloading, template target discovery, and reusable clap commands.
The crate is useful when an application wants a natural config file layout such as this:
include:
- config/server.yaml
- config/database.yaml
log:
level: info
Each included file can use the same schema shape, and relative include paths are
resolved from the file that declared them. The final config is still a normal
confique schema value.
Main Features
- Recursive include traversal with cycle detection.
- Relative include paths resolved from the declaring file.
.envloading before environment providers are evaluated.- Schema-declared environment variables without delimiter splitting.
- Figment metadata for runtime source tracking.
- TRACE-level source tracking events through
tracing. - Draft 7 JSON Schema generation for editor completion and basic schema checks.
- Field value validation in application code through
#[config(validate = Self::validate)], executed byload_configorconfig-validate. - YAML, TOML, JSON, and JSON5 template generation.
- TOML
#:schema, YAML Language Server schema modelines, and JSON/JSON5$schemafields for generated templates. - Opt-in YAML template splitting for nested sections marked with
x-tree-split. - Built-in clap subcommands for config templates, JSON Schema, and shell completions.
- A lower-level tree API for callers that do not use
confique.
Public Entry Points
Use these APIs for most applications:
load_config::<S>(path)loads the final schema.load_config_with_figment::<S>(path)loads the schema and returns the Figment graph used for source tracking.write_config_templates::<S>(config_path, output_path)writes the root template and recursively discovered child templates.write_config_schemas::<S>(output_path)writes root and section Draft 7 JSON Schemas.handle_config_command::<Cli, S>(command, config_path)handles built-in clap config commands.
Use load_config_tree when you need the traversal primitive without
confique.