pub struct Node { /* private fields */ }Expand description
A single element of a savefile.
Implementations§
Source§impl Node
impl Node
Sourcepub fn write(&self, path: impl AsRef<Path>) -> Result<()>
pub fn write(&self, path: impl AsRef<Path>) -> Result<()>
Writes a savefile to the file system.
Sourcepub fn properties(&self) -> impl Iterator<Item = (&str, &str)>
pub fn properties(&self) -> impl Iterator<Item = (&str, &str)>
Gets an iterator over all key-value properties on this node.
Sourcepub fn property(&self, key: impl AsRef<str>) -> Option<&str>
pub fn property(&self, key: impl AsRef<str>) -> Option<&str>
Gets the property value for a given key, if it exists. If multiple values are set, the first is returned.
Sourcepub fn has_property(&mut self, key: impl AsRef<str>) -> bool
pub fn has_property(&mut self, key: impl AsRef<str>) -> bool
Returns true if this node contains at least one property with the given key.
Sourcepub fn set_property(&mut self, key: impl Into<String>, value: impl Into<String>)
pub fn set_property(&mut self, key: impl Into<String>, value: impl Into<String>)
Sets the property value for a given key. If a value is already set, it is cleared.
Sourcepub fn add_property(&mut self, key: impl Into<String>, value: impl Into<String>)
pub fn add_property(&mut self, key: impl Into<String>, value: impl Into<String>)
Sets an additional property value for a given key. Existing values are kept.
Sourcepub fn clear_property(
&mut self,
key: impl AsRef<str>,
) -> impl Iterator<Item = String>
pub fn clear_property( &mut self, key: impl AsRef<str>, ) -> impl Iterator<Item = String>
Removes all property values for the given key and returns them.
Sourcepub fn clear_properties(
&mut self,
) -> impl Iterator<Item = (String, String)> + '_
pub fn clear_properties( &mut self, ) -> impl Iterator<Item = (String, String)> + '_
Removes all property values for this node and returns them.
Sourcepub fn extend_properties<K, V>(
&mut self,
properties: impl IntoIterator<Item = (K, V)>,
)
pub fn extend_properties<K, V>( &mut self, properties: impl IntoIterator<Item = (K, V)>, )
Adds the given key-value properties to this node.
Sourcepub fn children(&self) -> impl Iterator<Item = (&str, &Node)>
pub fn children(&self) -> impl Iterator<Item = (&str, &Node)>
Gets an iterator over all children of this node.
Sourcepub fn children_mut(&mut self) -> impl Iterator<Item = (&str, &mut Node)>
pub fn children_mut(&mut self) -> impl Iterator<Item = (&str, &mut Node)>
Gets a mutable iterator over all children of this node.
Sourcepub fn child(&self, key: &str) -> Option<&Node>
pub fn child(&self, key: &str) -> Option<&Node>
Gets the child for a given key, if it exists. If multiple children exist, the first is returned.
Sourcepub fn child_mut(&mut self, key: &str) -> Option<&mut Node>
pub fn child_mut(&mut self, key: &str) -> Option<&mut Node>
Gets a mutable reference to the child for a given key, if it exists. If multiple children exist, the first is returned.
Sourcepub fn has_child(&mut self, key: impl AsRef<str>) -> bool
pub fn has_child(&mut self, key: impl AsRef<str>) -> bool
Returns true if this node contains at least child with the given key.
Sourcepub fn set_child(&mut self, key: impl Into<String>, child: Node)
pub fn set_child(&mut self, key: impl Into<String>, child: Node)
Sets the child value for a given key. If a child is already set, it is cleared.
Sourcepub fn add_child(&mut self, key: impl Into<String>, child: Node)
pub fn add_child(&mut self, key: impl Into<String>, child: Node)
Sets an additional child value for a given key. Existing children are kept.
Sourcepub fn clear_child(
&mut self,
key: impl AsRef<str>,
) -> impl Iterator<Item = Node>
pub fn clear_child( &mut self, key: impl AsRef<str>, ) -> impl Iterator<Item = Node>
Removes all children for the given key and returns them.
Sourcepub fn clear_children(&mut self) -> impl Iterator<Item = (String, Node)> + '_
pub fn clear_children(&mut self) -> impl Iterator<Item = (String, Node)> + '_
Removes all children for this node and returns them.
Sourcepub fn extend_children<K>(
&mut self,
properties: impl IntoIterator<Item = (K, Node)>,
)
pub fn extend_children<K>( &mut self, properties: impl IntoIterator<Item = (K, Node)>, )
Adds the given children to this node.