[−][src]Struct cfg_lib::config::Config
Represents a CFG configuration.
Fields
no_duplicates: boolIf true, loaded configurations aren't allowed to have duplicate keys.
If false, duplicate keys are allowed, and values encountered later
overwrite values encountered earlier for the same key.
Methods
impl Config[src]
pub fn new() -> Self[src]
Return an empty configuration with default settings.
pub fn from_file(file_path: &str) -> StdResult<Self, ConfigError>[src]
Return a new configuration loaded from the file named by file_path.
pub fn add_include(&mut self, dir: &str)[src]
Add the directory dir to the end of the include path.
pub fn load_from_file(&mut self, file_path: &str) -> StdResult<(), ConfigError>[src]
Load the configuration from the file named by file_path.
pub fn load(&mut self, r: Box<dyn Read>) -> StdResult<(), ConfigError>[src]
Load the configuration from the reader r.
pub fn set_context(&mut self, context: HashMap<String, Value>)[src]
Set the given hashmap context as the place to look up identifiers
encountered in the configuration.
pub fn contains_key(&self, key: &str) -> bool[src]
Returns true if this configuration contains the simple key key
(i.e. not a path), else false.
pub fn as_mapping(
&self,
unwrap_configs: bool
) -> StdResult<HashMap<String, Value>, ConfigError>[src]
&self,
unwrap_configs: bool
) -> StdResult<HashMap<String, Value>, ConfigError>
Convert the configuration to a HashMap.
If unwrap_configs is true, nested configurations are also converted
to mappings. Otherwise, they are left as is.
pub fn get(&self, key: &str) -> StdResult<Value, ConfigError>[src]
Returns the value for the specified configuration key.
key can either be an identifier or a valid path.
Trait Implementations
impl Clone for Config[src]
impl Debug for Config[src]
impl Default for Config[src]
impl Display for Config[src]
impl PartialEq<Config> for Config[src]
impl StructuralPartialEq for Config[src]
Auto Trait Implementations
impl !RefUnwindSafe for Config
impl !Send for Config
impl !Sync for Config
impl Unpin for Config
impl !UnwindSafe for Config
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,
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> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T[src]
fn clone_into(&self, target: &mut T)[src]
impl<T> ToString for T where
T: Display + ?Sized, [src]
T: Display + ?Sized,
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.
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>,