Crate dinglebit_config
source · [−]Expand description
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());
}
Re-exports
Modules
Configuration from the environment variables.
Combine multiple configs to get configuration values from various places.
Extremely simplistic configuration from a file or string.
Macros
Create a config from a list of key/value pairs.
Traits
The main trait for this package. This should be implemented if you want to use this package with your configuration systems.