pub struct DataTree { /* private fields */ }
Expand description
YANG data tree.
Implementations§
source§impl DataTree
impl DataTree
sourcepub fn parse_file<F: AsRawFd>(
context: &Arc<Context>,
fd: F,
format: DataFormat,
parser_options: DataParserFlags,
validation_options: DataValidationFlags
) -> Result<DataTree, Error>
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.
sourcepub fn parse_string(
context: &Arc<Context>,
data: &str,
format: DataFormat,
parser_options: DataParserFlags,
validation_options: DataValidationFlags
) -> Result<DataTree, Error>
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.
sourcepub fn parse_op_string(
context: &Arc<Context>,
data: &str,
format: DataFormat,
op: DataOperation
) -> Result<DataTree, Error>
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.
sourcepub fn reference(&self) -> Option<DataNodeRef<'_>>
pub fn reference(&self) -> Option<DataNodeRef<'_>>
Returns a reference to the fist top-level data node, unless the data tree is empty.
sourcepub fn new_path(
&mut self,
path: &str,
value: Option<&str>,
output: bool
) -> Result<Option<DataNodeRef<'_>>, Error>
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).
sourcepub fn validate(&mut self, options: DataValidationFlags) -> Result<(), Error>
pub fn validate(&mut self, options: DataValidationFlags) -> Result<(), Error>
Fully validate the data tree.
sourcepub fn merge(&mut self, source: &DataTree) -> Result<(), Error>
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).
sourcepub fn add_implicit(&mut self, options: DataImplicitFlags) -> Result<(), Error>
pub fn add_implicit(&mut self, options: DataImplicitFlags) -> Result<(), Error>
Add any missing implicit nodes. Default nodes with a false “when” are not added.
sourcepub fn diff(
&self,
dtree: &DataTree,
options: DataDiffFlags
) -> Result<DataDiff, Error>
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.
sourcepub fn diff_apply(&mut self, diff: &DataDiff) -> Result<(), Error>
pub fn diff_apply(&mut self, diff: &DataDiff) -> Result<(), Error>
Apply the whole diff tree on the data tree.
sourcepub fn traverse(&self) -> impl Iterator<Item = DataNodeRef<'_>>
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).