feat: add ser/configrs

This commit is contained in:
2020-11-29 13:50:22 +08:00
parent 41447e002e
commit a5571a138b
5 changed files with 278 additions and 1 deletions

View File

@@ -0,0 +1,14 @@
use std::collections::HashMap;
fn main() {
let mut settings = config::Config::default();
settings
// Add in `./Settings.toml`
.merge(config::File::with_name("Settings")).unwrap()
// Add in settings from the environment (with a prefix of APP)
// Eg.. `APP_DEBUG=1 ./target/app` would set the `debug` key
.merge(config::Environment::with_prefix("APP")).unwrap();
// Print out our settings (as a HashMap)
println!("{:?}", settings.try_into::<HashMap<String, String>>().unwrap());
}