6 releases (2 stable)
1.1.0 | Jun 18, 2022 |
---|---|
1.0.0 | Jan 20, 2022 |
0.2.3 | Apr 18, 2021 |
0.1.0 | Apr 12, 2021 |
#465 in Configuration
17KB
349 lines
config.rs
Extremely simple configuration management.
lib.rs
:
Simplified configuration management.
This configuration package isn't meant to solve all of the configuration needs you'll ever need. Instead, it provides a trait for a config and then allows for including other confugiration systems as needed.
A simple environment config and file config are provided.
use dinglebit_config::{Config, Environment, MultiConfig, Simple};
use std::collections::HashMap;
fn main() {
let mut m = HashMap::new();
m.insert("foo", "bar");
let cfg = MultiConfig::new(vec![
Box::new(m),
Box::new(Simple::from_str("baz=foo").unwrap()),
]);
assert_eq!(cfg.must_get("foo"), "bar".to_string());
assert_eq!(cfg.must_get("baz"), "foo".to_string());
assert!(cfg.get("bar").is_none());
}
Dependencies
~1MB
~18K SLoC