pub struct NaturalXmlDiff<'a> { /* private fields */ }Expand description
A natural XML diff comparison of two documents.
Implementations§
Source§impl<'a> NaturalXmlDiff<'a>
impl<'a> NaturalXmlDiff<'a>
Sourcepub fn new(xml_a: &str, xml_b: &str) -> Result<Self, Error>
pub fn new(xml_a: &str, xml_b: &str) -> Result<Self, Error>
Construct a comparison between two XML documents from XML strings.
Sourcepub fn diff(&mut self) -> String
pub fn diff(&mut self) -> String
Returns a diff document for this comparison.
This diff document contains information on how to change document A
into document B. If this diff document is applied using apply,
the result should be semantically equivalent to document B.
Sourcepub fn verify(&mut self) -> Result<(), String>
pub fn verify(&mut self) -> Result<(), String>
Verify that a correct diff gets produced in one step.
This is a convenience function that first constructs the diff document and then immediately applies it to document A and checks that the result is semantically equal to document B. If not, it returns the XML for the erroneous document as part of the error.
It’s useful for testing purposes if you want to ensure that correct diffs are produced.
Sourcepub fn edits(&mut self) -> Vec<Edit>
pub fn edits(&mut self) -> Vec<Edit>
Returns a list of edits that transform document A into document B.
This is a low-level API to see the details of the edit operations.
Normally you’d use the higher level NaturalXmlDiff::diff method to
obtain the diff document.
Sourcepub fn partition(&mut self) -> Vec<(Range<usize>, Range<usize>)>
pub fn partition(&mut self) -> Vec<(Range<usize>, Range<usize>)>
Returns a list of partitions of a and b where nodes are equal.
A low-level API to see the details of the diffing algorithm.
Sourcepub fn diff_status(
&mut self,
) -> (impl Iterator<Item = (Node, Status)> + '_, impl Iterator<Item = (Node, Status)> + '_)
pub fn diff_status( &mut self, ) -> (impl Iterator<Item = (Node, Status)> + '_, impl Iterator<Item = (Node, Status)> + '_)
Returns an iterator of nodes in document a and b and their status.
A low-level API to see the details of the diffing algorithm.