Crate dinglebit_config[][src]

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

pub use env::Environment;
pub use multi::MultiConfig;
pub use simple::Error;
pub use simple::Simple;

Modules

env

Configuration from the environment variables.

multi

Combine multiple configs to get configuration values from various places.

simple

Extremely simplistic configuration from a file or string.

Macros

default_config

Create a config from a list of key/value pairs.

Traits

Config

The main trait for this package. This should be implemented if you want to use this package with your configuration systems.