[−][src]Struct justconfig::Config
Main struct representing a loaded configuration.
Implementations
impl Config
[src]
pub fn add_source(&mut self, source: Box<dyn Source>)
[src]
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");
pub fn root(&self) -> ConfPath
[src]
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()
.
pub fn get(&self, key: ConfPath) -> Result<StringItem, ConfigError>
[src]
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
Auto Trait Implementations
impl !RefUnwindSafe for Config
[src]
impl !Send for Config
[src]
impl !Sync for Config
[src]
impl Unpin for Config
[src]
impl !UnwindSafe for Config
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,