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>
impl<T> Patch<T>
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Creates a new empty Patch with a pre-allocated delta capacity.
Sourcepub fn with_conflict_output<C>(self, conflict_output: C) -> Selfwhere
C: ConflictOutput<T> + 'static,
pub fn with_conflict_output<C>(self, conflict_output: C) -> Selfwhere
C: ConflictOutput<T> + 'static,
Configures custom conflict resolution output behavior.
Sourcepub fn add_delta(&mut self, delta: impl Into<Delta<T>>)
pub fn add_delta(&mut self, delta: impl Into<Delta<T>>)
Appends a new delta modification record to this patch.
Sourcepub fn get_deltas(&self) -> &[Delta<T>]
pub fn get_deltas(&self) -> &[Delta<T>]
Returns an immutable slice reference to the deltas.
Sourcepub fn deltas(&self) -> &[Delta<T>]
pub fn deltas(&self) -> &[Delta<T>]
Returns a slice reference of deltas contained in this patch.
Sourcepub fn deltas_mut(&mut self) -> &mut [Delta<T>]
pub fn deltas_mut(&mut self) -> &mut [Delta<T>]
Returns a mutable slice reference to the deltas.
Sourcepub fn sort_deltas(&mut self)
pub fn sort_deltas(&mut self)
Sorts internal deltas in-place by source chunk position.
Sourcepub fn apply_to(&self, target: &[T]) -> Result<Vec<T>, PatchError>
pub fn apply_to(&self, target: &[T]) -> Result<Vec<T>, PatchError>
Applies this patch to a slice, returning a new patched vector.
Sourcepub fn apply_to_existing(&self, target: &mut Vec<T>) -> Result<(), PatchError>
pub fn apply_to_existing(&self, target: &mut Vec<T>) -> Result<(), PatchError>
Applies this patch in-place to an existing vector using shared &self.
Sourcepub fn restore(&self, target: &[T]) -> Result<Vec<T>, PatchError>
pub fn restore(&self, target: &[T]) -> Result<Vec<T>, PatchError>
Restores (un-applies) this patch on a target slice, returning a new restored vector.
Sourcepub fn restore_to_existing(&self, target: &mut Vec<T>) -> Result<(), PatchError>
pub fn restore_to_existing(&self, target: &mut Vec<T>) -> Result<(), PatchError>
Restores changes in-place on an existing vector using shared &self.
Sourcepub fn apply_fuzzy(
&self,
target: &[T],
max_fuzz: usize,
) -> Result<Vec<T>, PatchError>
pub fn apply_fuzzy( &self, target: &[T], max_fuzz: usize, ) -> Result<Vec<T>, PatchError>
Applies this patch using fuzzy context matching.