pub trait Node: Debug {
// Required methods
fn type_name(&self) -> &'static str;
fn as_array(&self) -> Option<&Array>;
fn as_array_mut(&mut self) -> Option<&mut Array>;
fn as_atomic_value(&self) -> Option<&Value>;
fn as_table_mut(&mut self) -> Option<&mut Table>;
fn get(&self, key: &PathComponent) -> Result<&dyn Node>;
fn get_mut(&mut self, key: &PathComponent) -> Result<&mut dyn Node>;
fn set(&mut self, key: &PathComponent, value: Value) -> Result<()>;
fn remove(&mut self, key: &PathComponent) -> Result<()>;
fn iter<'i>(
&'i self,
) -> Box<dyn Iterator<Item = (PathComponent, &'i dyn Node)> + 'i>;
// Provided methods
fn traverse(&self, path: &Path) -> TraversalResult<&dyn Node>
where Self: Sized { ... }
fn traverse_mut(&mut self, path: &Path) -> TraversalResult<&mut dyn Node>
where Self: Sized { ... }
}Expand description
A unified interface to toml_edit.
Required Methods§
Sourcefn as_array_mut(&mut self) -> Option<&mut Array>
fn as_array_mut(&mut self) -> Option<&mut Array>
Returns the node as mutable array, if possible.
Sourcefn as_atomic_value(&self) -> Option<&Value>
fn as_atomic_value(&self) -> Option<&Value>
Returns the node as atomic value, if possible.
Sourcefn as_table_mut(&mut self) -> Option<&mut Table>
fn as_table_mut(&mut self) -> Option<&mut Table>
Returns the node as mutable table, if possible.
Sourcefn get(&self, key: &PathComponent) -> Result<&dyn Node>
fn get(&self, key: &PathComponent) -> Result<&dyn Node>
Returns a reference to the child denoted by key.
Sourcefn get_mut(&mut self, key: &PathComponent) -> Result<&mut dyn Node>
fn get_mut(&mut self, key: &PathComponent) -> Result<&mut dyn Node>
Returns a mutable reference to the child denoted by key.
Sourcefn set(&mut self, key: &PathComponent, value: Value) -> Result<()>
fn set(&mut self, key: &PathComponent, value: Value) -> Result<()>
Sets the child denoted by key to the given value.
Sourcefn remove(&mut self, key: &PathComponent) -> Result<()>
fn remove(&mut self, key: &PathComponent) -> Result<()>
Removes the child denoted by key.
Provided Methods§
Sourcefn traverse(&self, path: &Path) -> TraversalResult<&dyn Node>where
Self: Sized,
fn traverse(&self, path: &Path) -> TraversalResult<&dyn Node>where
Self: Sized,
Returns a reference to the node that is reached by traversing
path from the current node.
Sourcefn traverse_mut(&mut self, path: &Path) -> TraversalResult<&mut dyn Node>where
Self: Sized,
fn traverse_mut(&mut self, path: &Path) -> TraversalResult<&mut dyn Node>where
Self: Sized,
Returns a mutable reference to the node that is reached by
traversing path from the current node.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".