pub struct Section<'a> { /* private fields */ }Expand description
One map of the tree, read under a dotted prefix.
Implementations§
Source§impl<'a> Section<'a>
impl<'a> Section<'a>
Sourcepub fn root(node: Option<&'a Node>) -> Result<Self, ConfigError>
pub fn root(node: Option<&'a Node>) -> Result<Self, ConfigError>
The root of a tree (None = nothing was loaded: every read is absent).
§Errors
ConfigError::Invalid when the root is not a map.
Sourcepub fn path_of(&self, key: &str) -> String
pub fn path_of(&self, key: &str) -> String
The dotted path of key in this section, for a caller’s own refusal.
Sourcepub fn only(&self, allowed: &[&str]) -> Result<(), ConfigError>
pub fn only(&self, allowed: &[&str]) -> Result<(), ConfigError>
Refuses every key that allowed does not name.
§Errors
ConfigError::Invalid for the first unknown key, with its origin.
Sourcepub fn scalar(
&self,
key: &str,
) -> Result<Option<(&'a str, &'a Origin)>, ConfigError>
pub fn scalar( &self, key: &str, ) -> Result<Option<(&'a str, &'a Origin)>, ConfigError>
The scalar at key and where it came from.
§Errors
ConfigError::Invalid when key holds a list or a map.
Sourcepub fn parse<T: FromStr>(
&self,
key: &str,
expect: &str,
) -> Result<Option<T>, ConfigError>
pub fn parse<T: FromStr>( &self, key: &str, expect: &str, ) -> Result<Option<T>, ConfigError>
The value at key, parsed; expect says what the setting accepts.
§Errors
As Self::scalar, and ConfigError::Invalid when it does not
parse.
Sourcepub fn strings(&self, key: &str) -> Result<Option<Vec<String>>, ConfigError>
pub fn strings(&self, key: &str) -> Result<Option<Vec<String>>, ConfigError>
A list of texts at key: a sequence of scalars, or one scalar as a
list of one.
§Errors
ConfigError::Invalid for a map or a sequence holding one.
Sourcepub fn items(&self, key: &str) -> Result<Vec<(String, &'a Node)>, ConfigError>
pub fn items(&self, key: &str) -> Result<Vec<(String, &'a Node)>, ConfigError>
The items of the sequence at key, each with its dotted path.
§Errors
ConfigError::Invalid when key is not a sequence.