Skip to main content

Node

Trait Node 

Source
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§

Source

fn type_name(&self) -> &'static str

Returns the node’s type name.

Source

fn as_array(&self) -> Option<&Array>

Returns the node as array, if possible.

Source

fn as_array_mut(&mut self) -> Option<&mut Array>

Returns the node as mutable array, if possible.

Source

fn as_atomic_value(&self) -> Option<&Value>

Returns the node as atomic value, if possible.

Source

fn as_table_mut(&mut self) -> Option<&mut Table>

Returns the node as mutable table, if possible.

Source

fn get(&self, key: &PathComponent) -> Result<&dyn Node>

Returns a reference to the child denoted by key.

Source

fn get_mut(&mut self, key: &PathComponent) -> Result<&mut dyn Node>

Returns a mutable reference to the child denoted by key.

Source

fn set(&mut self, key: &PathComponent, value: Value) -> Result<()>

Sets the child denoted by key to the given value.

Source

fn remove(&mut self, key: &PathComponent) -> Result<()>

Removes the child denoted by key.

Source

fn iter<'i>( &'i self, ) -> Box<dyn Iterator<Item = (PathComponent, &'i dyn Node)> + 'i>

Iterates over the children of this node.

Provided Methods§

Source

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.

Source

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".

Implementations on Foreign Types§

Source§

impl Node for Item

Source§

fn type_name(&self) -> &'static str

Source§

fn as_array(&self) -> Option<&Array>

Source§

fn as_array_mut(&mut self) -> Option<&mut Array>

Source§

fn as_atomic_value(&self) -> Option<&Value>

Source§

fn as_table_mut(&mut self) -> Option<&mut Table>

Source§

fn get(&self, key: &PathComponent) -> Result<&dyn Node>

Source§

fn get_mut(&mut self, key: &PathComponent) -> Result<&mut dyn Node>

Source§

fn set(&mut self, key: &PathComponent, value: Value) -> Result<()>

Source§

fn remove(&mut self, key: &PathComponent) -> Result<()>

Source§

fn iter<'i>( &'i self, ) -> Box<dyn Iterator<Item = (PathComponent, &'i dyn Node)> + 'i>

Source§

impl Node for Table

Source§

fn type_name(&self) -> &'static str

Source§

fn as_array(&self) -> Option<&Array>

Source§

fn as_array_mut(&mut self) -> Option<&mut Array>

Source§

fn as_atomic_value(&self) -> Option<&Value>

Source§

fn as_table_mut(&mut self) -> Option<&mut Table>

Source§

fn get(&self, key: &PathComponent) -> Result<&dyn Node>

Source§

fn get_mut(&mut self, key: &PathComponent) -> Result<&mut dyn Node>

Source§

fn set(&mut self, key: &PathComponent, value: Value) -> Result<()>

Source§

fn remove(&mut self, key: &PathComponent) -> Result<()>

Source§

fn iter<'i>( &'i self, ) -> Box<dyn Iterator<Item = (PathComponent, &'i dyn Node)> + 'i>

Source§

impl Node for Value

Source§

fn type_name(&self) -> &'static str

Source§

fn as_array(&self) -> Option<&Array>

Source§

fn as_array_mut(&mut self) -> Option<&mut Array>

Source§

fn as_atomic_value(&self) -> Option<&Value>

Source§

fn as_table_mut(&mut self) -> Option<&mut Table>

Source§

fn get(&self, key: &PathComponent) -> Result<&dyn Node>

Source§

fn get_mut(&mut self, key: &PathComponent) -> Result<&mut dyn Node>

Source§

fn set(&mut self, key: &PathComponent, value: Value) -> Result<()>

Source§

fn remove(&mut self, key: &PathComponent) -> Result<()>

Source§

fn iter<'i>( &'i self, ) -> Box<dyn Iterator<Item = (PathComponent, &'i dyn Node)> + 'i>

Implementors§