NaturalXmlDiff

Struct NaturalXmlDiff 

Source
pub struct NaturalXmlDiff<'a> { /* private fields */ }
Expand description

A natural XML diff comparison of two documents.

Implementations§

Source§

impl<'a> NaturalXmlDiff<'a>

Source

pub fn new(xml_a: &str, xml_b: &str) -> Result<Self, Error>

Construct a comparison between two XML documents from XML strings.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn serialize(&mut self, node: Node) -> String

Serialize a node to a string.

You can get a node if you access the edits and have an InsertContent::XmlNode

Source

pub fn xot(&self) -> &Xot<'_>

Access to the low-level Xot instance - this is useful if you need access to XML values and names.

Normally should not be needed if you stick to the high-level API.

Auto Trait Implementations§

§

impl<'a> Freeze for NaturalXmlDiff<'a>

§

impl<'a> RefUnwindSafe for NaturalXmlDiff<'a>

§

impl<'a> Send for NaturalXmlDiff<'a>

§

impl<'a> Sync for NaturalXmlDiff<'a>

§

impl<'a> Unpin for NaturalXmlDiff<'a>

§

impl<'a> UnwindSafe for NaturalXmlDiff<'a>

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>,

Source§

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>,

Source§

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.