Profig
A Config Framework with schema validation, sample configs, and doc generation
Load your config files, validate them, document them, all with
#[derive(Profig)].
Features
- Easy config schema definition with
#[derive(Profig)] - Set strict formats with
#[profig(format="json,toml")] - Field-level metadata using
#[profig(doc = "...", default = "...")] - Built-in validation with
#[profig(min = 1, max = 10, regex = "...")] - Multi format support: TOML, JSON, YAML
- Automatically load data by automatically determining file type (ie
.json/.toml/.yaml) - Automatic sample generation with one
sample_config("filename.format")(eg, sample_config("sample.json")) - Docs generation using the provided
doc="..."metadata fields
Example Usage
use Profig;
// Config Schema struct
// Main function
Formats Supported
Currently, profig supports the following config file types:
JSONTOMLYAML
Each format is gated behind their individual feature flags. Enable the features in Cargo.toml as follows:
[]
= "0.1"
= ["toml", "json", "yaml"] # choose the features as per your requirements
Full Documentation
See DOCS.md for complete documentation and guide on usage of profig.
Installation
Run the following command to install the crate:
Or, for format features:
Alternatively, you can directly add a Cargo.toml entry as follows:
[]
= { = "0.1", = ["toml", "yaml"] }
Status
Profig is currently in v0.1, stable for usage but still in very early stages.
Links
License
MIT