Skip to main content

lyd_diff_tree

Function lyd_diff_tree 

Source
pub unsafe extern "C" fn lyd_diff_tree(
    first: *const lyd_node,
    second: *const lyd_node,
    options: u16,
    diff: *mut *mut lyd_node,
) -> Type
Expand description

@brief 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.

The diff tree is completely independent on the @p first and @p second trees, meaning all the information about the change is stored in the diff and the trees are not needed.

!! Caution !! The diff tree should never be validated because it may easily not be valid! For example, when data from one case branch are deleted and data from another branch created - data from both branches are then stored in the diff tree simultaneously.

@param[in] first First data tree. @param[in] second Second data tree. @param[in] options Bitmask of options flags, see @ref diffoptions. @param[out] diff Generated diff, NULL if there are no differences. @return LY_SUCCESS on success, @return LY_ERR on error.