dotcfg 0.3.0 is outCustom directories and project config discovery are now available.See what’s new →
dotcfg
Star on GitHub
Flexible configuration for Rust

Config that fits your application.

dotcfg handles where configuration lives, how it is encoded, and how you read it — without forcing one directory strategy or one access pattern.

Get started

Start with the format you need.

Full setup guide →
Cargo.toml
[dependencies]
dotcfg = "0.3.0"
serde = { version = "1", features = ["derive"] }

Published release: 0.3.0. Explore more on the examples page.

Your first config

Load a typed Rust configuration.

src/main.rs
use dotcfg::DotCfg;use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, Default)]struct Config {    username: String,    port: u16,} fn main() -> Result<(), Box<dyn std::error::Error>> {    let cfg = DotCfg::new("mytool");    cfg.save(&Config { username: "tayo".into(), port: 8080 })?;    let config: Option<Config> = cfg.load()?;    Ok(())}
Practical examples

Common things you’ll do with config.

All examples →

Need the full API?

Every method, type, and error is in the Rust reference.

Open docs.rs ↗