pub struct Config {
pub no_duplicates: bool,
/* private fields */
}Expand description
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.
Implementations§
Source§impl Config
impl Config
Sourcepub fn from_file(file_path: &str) -> StdResult<Self, ConfigError>
pub fn from_file(file_path: &str) -> StdResult<Self, ConfigError>
Return a new configuration loaded from the file named by file_path.
Sourcepub fn add_include(&mut self, dir: &str)
pub fn add_include(&mut self, dir: &str)
Add the directory dir to the end of the include path.
Sourcepub fn load_from_file(&mut self, file_path: &str) -> StdResult<(), ConfigError>
pub fn load_from_file(&mut self, file_path: &str) -> StdResult<(), ConfigError>
Load the configuration from the file named by file_path.
Sourcepub fn load(&mut self, r: Box<dyn Read>) -> StdResult<(), ConfigError>
pub fn load(&mut self, r: Box<dyn Read>) -> StdResult<(), ConfigError>
Load the configuration from the reader r.
Sourcepub fn set_context(&mut self, context: HashMap<String, Value>)
pub fn set_context(&mut self, context: HashMap<String, Value>)
Set the given hashmap context as the place to look up identifiers
encountered in the configuration.
Sourcepub fn contains_key(&self, key: &str) -> bool
pub fn contains_key(&self, key: &str) -> bool
Returns true if this configuration contains the simple key key
(i.e. not a path), else false.
Sourcepub fn as_mapping(
&self,
unwrap_configs: bool,
) -> StdResult<HashMap<String, Value>, ConfigError>
pub fn as_mapping( &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.