Configuration
config
config
⮳ is a layered configuration system for Rust applications. It reads from JSON, TOML, YAML, INI, RON, JSON5 files.
fn main() { todo!(); }
confy
use serde::Deserialize;
use serde::Serialize;
#[derive(Serialize, Deserialize, Debug)]
struct MyConfig {
version: u8,
api_key: String,
}
/// `MyConfig` implements `Default`
impl ::std::default::Default for MyConfig {
fn default() -> Self {
Self {
version: 0,
api_key: "".into(),
}
}
}
fn main() -> Result<(), confy::ConfyError> {
let cfg: MyConfig = confy::load("my-app-name", None)?;
// confy::store("my-app-name", None, cfg)?;
println!("{:?}", cfg);
Ok(())
}
[configuration: expand; add text (P1)](https://github.com/john-cd/rust_howto/issues/270)