pub enum Node {
Object(Object),
Array(Array),
Scalar(Scalar),
}Expand description
A node in the tree: an object, an array, or a scalar.
Variants§
Object(Object)
An object, with or without braces.
Array(Array)
An array.
Scalar(Scalar)
A string, number, bool, null, date, instant, or duration.
Implementations§
Source§impl Node
impl Node
Sourcepub fn new(value: impl Into<Value>) -> Result<Self, Error>
pub fn new(value: impl Into<Value>) -> Result<Self, Error>
A node for a value, printed in canonical form, with no decor. Use it to replace a value through Member::value_mut or Item::value_mut, which keeps the decor around the value.
let mut document: soml::Document = "port: 1 # The default.".parse()?;
let root = document.root_mut().as_object_mut().unwrap();
*root.members_mut()[0].value_mut() = soml::tree::Node::new(8080)?;
assert_eq!(document.to_string(), "port: 8080 # The default.");§Errors
Returns an error when the value holds something SOML cannot represent: NaN, a carriage return, or nesting of 100 levels or more, because a node is always inside a collection.
Sourcepub const fn as_object_mut(&mut self) -> Option<&mut Object>
pub const fn as_object_mut(&mut self) -> Option<&mut Object>
The object, if this node is one, to change.
Sourcepub const fn as_array_mut(&mut self) -> Option<&mut Array>
pub const fn as_array_mut(&mut self) -> Option<&mut Array>
The array, if this node is one, to change.
Trait Implementations§
impl StructuralPartialEq for Node
Auto Trait Implementations§
impl Freeze for Node
impl RefUnwindSafe for Node
impl Send for Node
impl Sync for Node
impl Unpin for Node
impl UnsafeUnpin for Node
impl UnwindSafe for Node
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more