Skip to main content

Delta

Struct Delta 

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

Source

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.

Source

pub fn source(&self) -> &Chunk<T>

Returns a reference to the source chunk.

Source

pub fn source_mut(&mut self) -> &mut Chunk<T>

Returns a mutable reference to the source chunk.

Source

pub fn target(&self) -> &Chunk<T>

Returns a reference to the target chunk.

Source

pub fn target_mut(&mut self) -> &mut Chunk<T>

Returns a mutable reference to the target chunk.

Source

pub fn delta_type(&self) -> DeltaType

Returns the type of this delta.

Source

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.

Source

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

Verifies that the source chunk matches the target sequence and applies the delta in-place if valid.

Source

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

Applies this delta to the target vector using its source chunk position.

Source

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

Applies this delta to the target vector starting at an explicit position.

Source

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

Restores (un-applies) this delta, reverting the target sequence back to its original state.

Source

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

Applies fuzzy patch matching at a given position with context tolerances. Applies fuzzy patch matching at a given position with context tolerances.

Source

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.

Trait Implementations§

Source§

impl<T> AsRef<Delta<T>> for Delta<T>

Source§

fn as_ref(&self) -> &Delta<T>

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<T: Clone> Clone for Delta<T>

Source§

fn clone(&self) -> Delta<T>

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 Delta<T>

Source§

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

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

impl<'de, T> Deserialize<'de> for Delta<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 Delta<T>

Source§

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

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

impl<T: Eq> Eq for Delta<T>

Source§

impl<T> From<Box<Delta<T>>> for Delta<T>

Source§

fn from(boxed: Box<Delta<T>>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<ChangeDelta<T>> for Delta<T>

Source§

fn from(change: ChangeDelta<T>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<DeleteDelta<T>> for Delta<T>

Source§

fn from(delete: DeleteDelta<T>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<EqualDelta<T>> for Delta<T>

Source§

fn from(equal: EqualDelta<T>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<InsertDelta<T>> for Delta<T>

Source§

fn from(insert: InsertDelta<T>) -> Self

Converts to this type from the input type.
Source§

impl<T: Hash> Hash for Delta<T>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T: PartialEq> PartialEq for Delta<T>

Source§

fn eq(&self, other: &Delta<T>) -> 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 Delta<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
Source§

impl<T: PartialEq> StructuralPartialEq for Delta<T>

Auto Trait Implementations§

§

impl<T> Freeze for Delta<T>
where Chunk<T>: Freeze,

§

impl<T> RefUnwindSafe for Delta<T>
where Chunk<T>: RefUnwindSafe,

§

impl<T> Send for Delta<T>
where Chunk<T>: Send,

§

impl<T> Sync for Delta<T>
where Chunk<T>: Sync,

§

impl<T> Unpin for Delta<T>
where Chunk<T>: Unpin,

§

impl<T> UnsafeUnpin for Delta<T>
where Chunk<T>: UnsafeUnpin,

§

impl<T> UnwindSafe for Delta<T>
where Chunk<T>: UnwindSafe,

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.