pub struct Config { /* private fields */ }
Expand description

Main struct representing a loaded configuration.

Implementations

Add a configuration source to the configuration system.

Each configuration source must implement the Source trait. Multiple configuration sources can be added and are queried from first to last. The first configuration source that returns values for a configuration item will be used. All following configuration sources will be ignored for this configuration item.

Example
let mut conf = Config::default();

let mut source_1 = Defaults::default();
source_1.set(conf.root().push_all(&["myitem_A"]), "source_1", "source 1");
conf.add_source(source_1);

let mut source_2 = Defaults::default();
source_2.set(conf.root().push_all(&["myitem_A"]), "source_2", "source 2");
source_2.set(conf.root().push_all(&["myitem_B"]), "source_2", "source 2");
conf.add_source(source_2);

let value: String = conf.get(ConfPath::from(&["myitem_A"])).value().unwrap();
assert_eq!(value, "source_1");

let value: String = conf.get(ConfPath::from(&["myitem_B"])).value().unwrap();
assert_eq!(value, "source_2");

Convenience method to get a ConfPath instance.

Can be used to get a ConfPath instance to build configuration paths. If this ConfPath instance is used for all calls to the configuration library all configuration values can be enumerated. For details see ConfPath::children().

Get the configuration value identified by the passed ConfPath.

This method is the root of every configuration pipeline. For usage examples see the crates documentation.

Trait Implementations

Create a new configuration store.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.