pub enum Node {
Scalar(String, Origin),
Seq(Vec<Node>),
Map(BTreeMap<String, Node>),
}Expand description
One node of a configuration tree.
Variants§
Scalar(String, Origin)
A scalar, with the place it came from.
Seq(Vec<Node>)
An ordered sequence.
Map(BTreeMap<String, Node>)
A mapping, ordered by key so that a rendered tree is stable.
Implementations§
Source§impl Node
impl Node
Sourcepub fn origin(&self) -> Option<&Origin>
pub fn origin(&self) -> Option<&Origin>
The origin of a scalar; None for a sequence or a map, which have no
single one.
Sourcepub fn get(&self, path: &str) -> Option<&Self>
pub fn get(&self, path: &str) -> Option<&Self>
Follows a dotted path — transport.mtu — through maps.
Sourcepub fn merge(&mut self, other: Self) -> Result<(), ConfigError>
pub fn merge(&mut self, other: Self) -> Result<(), ConfigError>
Merges other into self, with other winning.
Maps merge key by key. Anything else replaces. A key spelled +name
in other appends to the sequence at name instead of replacing it,
and appending to something that is not a sequence is an error rather
than a silent replacement — a drop-in that meant to extend a list and
found a scalar has a mistake in it, and saying so is the whole point.
§Errors
ConfigError::AppendToNonSeq when +name meets a non-sequence,
ConfigError::TooDeep past MAX_NESTING_DEPTH.
zerodds-lint: recursion-depth 32