pub enum Node {
Null,
Bool(bool),
Int(i64),
UInt(u64),
Float(f64),
String(String),
Array(Vec<Node>),
Object(NodeMap),
}Expand description
A dynamically typed value that round-trips through YAML and JSON while preserving object key order.
Entry config read from a file is stored as a Node; plugins receive it
wrapped in a cordis::Value and recover it with
downcast::<Node>(). Unlike serde_json::Value or
serde_yaml_ng::Value, object keys keep their file order, which keeps
serialized output stable and friendly to diffs and file watchers.
Variants§
Null
Absent value (null / ~).
Bool(bool)
Boolean literal.
Int(i64)
Signed integer.
UInt(u64)
Unsigned integer outside i64 range.
Float(f64)
Floating-point number.
String(String)
String literal (subject to ${{ ... }} interpolation).
Array(Vec<Node>)
Array of nodes.
Object(NodeMap)
Ordered object.
Implementations§
Source§impl Node
impl Node
Sourcepub fn as_str(&self) -> Option<&str>
pub fn as_str(&self) -> Option<&str>
Return the string contents, or None for any other node kind.
Sourcepub fn as_bool(&self) -> Option<bool>
pub fn as_bool(&self) -> Option<bool>
Return the boolean value, or None for any other node kind.
Sourcepub fn as_object(&self) -> Option<&NodeMap>
pub fn as_object(&self) -> Option<&NodeMap>
Return the object entries, or None for any other node kind.
Sourcepub fn as_array(&self) -> Option<&[Node]>
pub fn as_array(&self) -> Option<&[Node]>
Return the array items, or None for any other node kind.
Sourcepub fn is_null(&self) -> bool
pub fn is_null(&self) -> bool
Whether this node is Node::Null.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Node
impl<'de> Deserialize<'de> for Node
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Source§impl Index<&str> for Node
Indexes object keys, panicking only when the node is not an object.
impl Index<&str> for Node
Indexes object keys, panicking only when the node is not an object.
Missing keys yield Node::Null, which keeps assertions on parsed
config concise (assert_eq!(node["missing"], Node::Null)).