Struct yang2::data::DataTree

source ·
pub struct DataTree { /* private fields */ }
Expand description

YANG data tree.

Implementations§

source§

impl DataTree

source

pub fn new(context: &Arc<Context>) -> DataTree

Create new empty data tree.

source

pub fn parse_file<F: AsRawFd>( context: &Arc<Context>, fd: F, format: DataFormat, parser_options: DataParserFlags, validation_options: DataValidationFlags ) -> Result<DataTree, Error>

Parse (and validate) input data as a YANG data tree.

source

pub fn parse_string( context: &Arc<Context>, data: &str, format: DataFormat, parser_options: DataParserFlags, validation_options: DataValidationFlags ) -> Result<DataTree, Error>

Parse (and validate) input data as a YANG data tree.

source

pub fn parse_op_string( context: &Arc<Context>, data: &str, format: DataFormat, op: DataOperation ) -> Result<DataTree, Error>

Parse YANG data into an operation data tree.

source

pub fn reference(&self) -> Option<DataNodeRef<'_>>

Returns a reference to the fist top-level data node, unless the data tree is empty.

source

pub fn new_path( &mut self, path: &str, value: Option<&str>, output: bool ) -> Result<Option<DataNodeRef<'_>>, Error>

Create a new node or modify existing one in the data tree based on a path.

If path points to a list key and the list instance does not exist, the key value from the predicate is used and value is ignored. Also, if a leaf-list is being created and both a predicate is defined in path and value is set, the predicate is preferred.

For key-less lists and state leaf-lists, positional predicates can be used. If no preciate is used for these nodes, they are always created.

The output parameter can be used to change the behavior to ignore RPC/action input schema nodes and use only output ones.

Returns the last created or modified node (if any).

source

pub fn remove(&mut self, path: &str) -> Result<(), Error>

Remove a data node.

source

pub fn validate(&mut self, options: DataValidationFlags) -> Result<(), Error>

Fully validate the data tree.

source

pub fn duplicate(&self) -> Result<DataTree, Error>

Create a copy of the data tree.

source

pub fn merge(&mut self, source: &DataTree) -> Result<(), Error>

Merge the source data tree into the target data tree. Merge may not be complete until validation is called on the resulting data tree (data from more cases may be present, default and non-default values).

source

pub fn add_implicit(&mut self, options: DataImplicitFlags) -> Result<(), Error>

Add any missing implicit nodes. Default nodes with a false “when” are not added.

source

pub fn diff( &self, dtree: &DataTree, options: DataDiffFlags ) -> Result<DataDiff, Error>

Learn the differences between 2 data trees.

The resulting diff is represented as a data tree with specific metadata from the internal ‘yang’ module. Most importantly, every node has an effective ‘operation’ metadata. If there is none defined on the node, it inherits the operation from the nearest parent. Top-level nodes must always have the ‘operation’ metadata defined. Additional metadata (‘orig-default’, ‘value’, ‘orig-value’, ‘key’, ‘orig-key’) are used for storing more information about the value in the first or the second tree.

source

pub fn diff_apply(&mut self, diff: &DataDiff) -> Result<(), Error>

Apply the whole diff tree on the data tree.

source

pub fn traverse(&self) -> impl Iterator<Item = DataNodeRef<'_>>

Returns an iterator over all elements in the data tree and its sibling trees (depth-first search algorithm).

Trait Implementations§

source§

impl<'a> Binding<'a> for DataTree

§

type CType = lyd_node

§

type Container = Arc<Context>

source§

unsafe fn from_raw(context: &'a Arc<Context>, raw: *mut lyd_node) -> DataTree

source§

unsafe fn from_raw_opt( container: &'a Self::Container, raw: *mut Self::CType ) -> Option<Self>

source§

impl Data for DataTree

source§

fn find_xpath(&self, xpath: &str) -> Result<Set<'_, DataNodeRef<'_>>, Error>

Search in the given data for instances of nodes matching the provided XPath. Read more
source§

fn find_path(&self, path: &str) -> Result<DataNodeRef<'_>, Error>

Search in the given data for a single node matching the provided XPath. Read more
source§

fn print_file<F: AsRawFd>( &self, fd: F, format: DataFormat, options: DataPrinterFlags ) -> Result<(), Error>

Print data tree in the specified format.
source§

fn print_string( &self, format: DataFormat, options: DataPrinterFlags ) -> Result<Option<String>, Error>

Print data tree in the specified format.
source§

impl Debug for DataTree

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Drop for DataTree

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl Send for DataTree

source§

impl Sync for DataTree

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.