Skip to main content

Patch

Struct Patch 

Source
pub struct Patch<T> { /* private fields */ }
Expand description

Represents a collection of deltas to transform a source sequence into a target sequence.

Implementations§

Source§

impl<T> Patch<T>

Source

pub fn new() -> Self

Creates a new empty Patch.

Source

pub fn with_capacity(capacity: usize) -> Self

Creates a new empty Patch with a pre-allocated delta capacity.

Source

pub fn with_conflict_output<C>(self, conflict_output: C) -> Self
where C: ConflictOutput<T> + 'static,

Configures custom conflict resolution output behavior.

Source

pub fn add_delta(&mut self, delta: impl Into<Delta<T>>)

Appends a new delta modification record to this patch.

Source

pub fn get_deltas(&self) -> &[Delta<T>]

Returns an immutable slice reference to the deltas.

Source

pub fn deltas(&self) -> &[Delta<T>]

Returns a slice reference of deltas contained in this patch.

Source

pub fn deltas_mut(&mut self) -> &mut [Delta<T>]

Returns a mutable slice reference to the deltas.

Source

pub fn sort_deltas(&mut self)

Sorts internal deltas in-place by source chunk position.

Source

pub fn apply_to(&self, target: &[T]) -> Result<Vec<T>, PatchError>
where T: Clone + PartialEq,

Applies this patch to a slice, returning a new patched vector.

Source

pub fn apply_to_existing(&self, target: &mut Vec<T>) -> Result<(), PatchError>
where T: Clone + PartialEq,

Applies this patch in-place to an existing vector using shared &self.

Source

pub fn restore(&self, target: &[T]) -> Result<Vec<T>, PatchError>
where T: Clone + PartialEq,

Restores (un-applies) this patch on a target slice, returning a new restored vector.

Source

pub fn restore_to_existing(&self, target: &mut Vec<T>) -> Result<(), PatchError>
where T: Clone + PartialEq,

Restores changes in-place on an existing vector using shared &self.

Source

pub fn apply_fuzzy( &self, target: &[T], max_fuzz: usize, ) -> Result<Vec<T>, PatchError>
where T: Clone + PartialEq,

Applies this patch using fuzzy context matching.

Source

pub fn generate( original: &[T], revised: &[T], changes: &[Change], include_equals: bool, ) -> Self
where T: Clone,

Constructs a Patch from sequences and raw algorithm Change records.

Trait Implementations§

Source§

impl<T: Clone> Clone for Patch<T>
where Delta<T>: Clone,

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for Patch<T>

Source§

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

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

impl<T> Default for Patch<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de, T> Deserialize<'de> for Patch<T>
where T: Deserialize<'de>,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<T: Display> Display for Patch<T>

Source§

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

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

impl<T: Eq> Eq for Patch<T>

Source§

impl<T: PartialEq> PartialEq for Patch<T>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<T> Serialize for Patch<T>
where T: Serialize,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for Patch<T>

§

impl<T> !Send for Patch<T>

§

impl<T> !Sync for Patch<T>

§

impl<T> !UnwindSafe for Patch<T>

§

impl<T> Freeze for Patch<T>

§

impl<T> Unpin for Patch<T>
where Vec<Delta<T>>: Unpin, Option<Vec<T>>: Unpin, Option<Box<dyn ConflictOutput<T>>>: Unpin,

§

impl<T> UnsafeUnpin for Patch<T>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.