pub struct ConfigReader { /* private fields */ }Expand description
A configuration reader over a MultiLevelMap, with ${...} substitution.
Implementations§
Source§impl ConfigReader
impl ConfigReader
Sourcepub fn load(path: &str) -> Result<Self, ConfigError>
pub fn load(path: &str) -> Result<Self, ConfigError>
Load a configuration file and resolve references (Java new ConfigReader(path)).
Sourcepub fn load_raw(path: &str) -> Result<Self, ConfigError>
pub fn load_raw(path: &str) -> Result<Self, ConfigError>
Load a configuration file without resolving references
(Java load(path, false) — used while merging base configuration files).
Sourcepub fn from_yaml_text(text: &str) -> Result<Self, ConfigError>
pub fn from_yaml_text(text: &str) -> Result<Self, ConfigError>
Build a reader from in-memory YAML text and resolve references — used
for embedded built-in templates (e.g. default-log-context.yaml),
the Rust analog of a library-jar classpath resource. The resources/
roots are application-owned in this port, so a library default ships
compiled-in via include_str! instead of shadowing a file name.
Sourcepub fn from_map(map: BTreeMap<String, ConfigValue>) -> Self
pub fn from_map(map: BTreeMap<String, ConfigValue>) -> Self
Build a reader from an existing nested map and resolve references
(Java load(Map)).
Sourcepub fn get(&self, key: &str) -> Option<ConfigValue>
pub fn get(&self, key: &str) -> Option<ConfigValue>
Retrieve a value by composite key. None for a missing key, an explicit
null, or an unresolvable ${...} reference (Java returns null in each
case).
Sourcepub fn get_or(&self, key: &str, default: ConfigValue) -> ConfigValue
pub fn get_or(&self, key: &str, default: ConfigValue) -> ConfigValue
Retrieve a value by composite key with a default (Java get(key, defaultValue)).
Sourcepub fn get_property(&self, key: &str) -> Option<String>
pub fn get_property(&self, key: &str) -> Option<String>
Retrieve a value enforced as a string (Java getProperty).
Sourcepub fn get_property_or(&self, key: &str, default: &str) -> String
pub fn get_property_or(&self, key: &str, default: &str) -> String
Retrieve a value enforced as a string, with a default (Java getProperty(key, default)).
Sourcepub fn exists(&self, key: &str) -> bool
pub fn exists(&self, key: &str) -> bool
True when the key resolves to a non-null value (Java exists).
pub fn is_empty(&self) -> bool
Sourcepub fn get_map(&self) -> &MultiLevelMap
pub fn get_map(&self) -> &MultiLevelMap
The raw underlying tree, without substitution (Java getMap).
Sourcepub fn get_composite_key_values(&self) -> &BTreeMap<String, ConfigValue>
pub fn get_composite_key_values(&self) -> &BTreeMap<String, ConfigValue>
Flat map of composite key-values with substitution applied, computed once
and cached (Java getCompositeKeyValues).