pub struct Delta<T> { /* private fields */ }Expand description
Represents a single modification delta between a source chunk and a target chunk.
Implementations§
Source§impl<T> Delta<T>
impl<T> Delta<T>
Sourcepub fn new(delta_type: DeltaType, source: Chunk<T>, target: Chunk<T>) -> Self
pub fn new(delta_type: DeltaType, source: Chunk<T>, target: Chunk<T>) -> Self
Creates a new Delta with the specified type, source, and target chunks.
Sourcepub fn source_mut(&mut self) -> &mut Chunk<T>
pub fn source_mut(&mut self) -> &mut Chunk<T>
Returns a mutable reference to the source chunk.
Sourcepub fn target_mut(&mut self) -> &mut Chunk<T>
pub fn target_mut(&mut self) -> &mut Chunk<T>
Returns a mutable reference to the target chunk.
Sourcepub fn delta_type(&self) -> DeltaType
pub fn delta_type(&self) -> DeltaType
Returns the type of this delta.
Sourcepub fn verify_chunk_to_fit_target(
&self,
target: &[T],
) -> Result<VerifyChunk, PatchError>where
T: PartialEq,
pub fn verify_chunk_to_fit_target(
&self,
target: &[T],
) -> Result<VerifyChunk, PatchError>where
T: PartialEq,
Verifies whether the source chunk of this delta fits the provided target sequence.
Sourcepub fn verify_and_apply_to(
&self,
target: &mut Vec<T>,
) -> Result<VerifyChunk, PatchError>
pub fn verify_and_apply_to( &self, target: &mut Vec<T>, ) -> Result<VerifyChunk, PatchError>
Verifies that the source chunk matches the target sequence and applies the delta in-place if valid.
Sourcepub fn apply_to(&self, target: &mut Vec<T>) -> Result<(), PatchError>
pub fn apply_to(&self, target: &mut Vec<T>) -> Result<(), PatchError>
Applies this delta to the target vector using its source chunk position.
Sourcepub fn apply_at(
&self,
target: &mut Vec<T>,
pos: usize,
) -> Result<(), PatchError>
pub fn apply_at( &self, target: &mut Vec<T>, pos: usize, ) -> Result<(), PatchError>
Applies this delta to the target vector starting at an explicit position.
Sourcepub fn restore(&self, target: &mut Vec<T>) -> Result<(), PatchError>
pub fn restore(&self, target: &mut Vec<T>) -> Result<(), PatchError>
Restores (un-applies) this delta, reverting the target sequence back to its original state.
Sourcepub fn apply_fuzzy_to_at(
&self,
target: &mut Vec<T>,
_fuzz: usize,
position: usize,
) -> Result<(), PatchError>
pub fn apply_fuzzy_to_at( &self, target: &mut Vec<T>, _fuzz: usize, position: usize, ) -> Result<(), PatchError>
Applies fuzzy patch matching at a given position with context tolerances. Applies fuzzy patch matching at a given position with context tolerances.
Sourcepub fn with_chunks(&self, source: Chunk<T>, target: Chunk<T>) -> Self
pub fn with_chunks(&self, source: Chunk<T>, target: Chunk<T>) -> Self
Returns a new instance of Delta with customized source and target chunk values.