pub struct Chunk<T> { /* private fields */ }Expand description
Represents a contiguous sub-sequence (chunk) of items participating in a diff/patch operation.
Implementations§
Source§impl<T> Chunk<T>
impl<T> Chunk<T>
Sourcepub fn new(
position: usize,
lines: Vec<T>,
change_position: Option<Vec<usize>>,
) -> Self
pub fn new( position: usize, lines: Vec<T>, change_position: Option<Vec<usize>>, ) -> Self
Creates a new Chunk with a starting position, lines, and optional positions of modified lines.
Sourcepub fn with_lines(position: usize, lines: Vec<T>) -> Self
pub fn with_lines(position: usize, lines: Vec<T>) -> Self
Convenience constructor creating a Chunk without granular line-change tracking indices.
Sourcepub fn verify_chunk(&self, target: &[T]) -> Result<VerifyChunk, PatchError>where
T: PartialEq,
pub fn verify_chunk(&self, target: &[T]) -> Result<VerifyChunk, PatchError>where
T: PartialEq,
Verifies that this chunk’s saved lines match the corresponding region in the target slice.
Sourcepub fn verify_chunk_at(
&self,
target: &[T],
fuzz: usize,
position: usize,
) -> Result<VerifyChunk, PatchError>where
T: PartialEq,
pub fn verify_chunk_at(
&self,
target: &[T],
fuzz: usize,
position: usize,
) -> Result<VerifyChunk, PatchError>where
T: PartialEq,
Verifies that this chunk matches the target sequence starting at position, taking fuzz context into account.
Sourcepub fn lines_mut(&mut self) -> &mut Vec<T>
pub fn lines_mut(&mut self) -> &mut Vec<T>
Returns a mutable slice reference to the chunk’s lines.
Sourcepub fn set_lines(&mut self, lines: Vec<T>)
pub fn set_lines(&mut self, lines: Vec<T>)
Sets or replaces the lines stored inside this chunk.
Sourcepub fn change_position(&self) -> Option<&[usize]>
pub fn change_position(&self) -> Option<&[usize]>
Returns an optional slice reference to the change position indices, if present.
Trait Implementations§
Source§impl<'de, T> Deserialize<'de> for Chunk<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for Chunk<T>where
T: Deserialize<'de>,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl<T: Eq> Eq for Chunk<T>
impl<T: PartialEq> StructuralPartialEq for Chunk<T>
Auto Trait Implementations§
impl<T> Freeze for Chunk<T>
impl<T> RefUnwindSafe for Chunk<T>where
Vec<T>: RefUnwindSafe,
impl<T> Send for Chunk<T>
impl<T> Sync for Chunk<T>
impl<T> Unpin for Chunk<T>
impl<T> UnsafeUnpin for Chunk<T>where
Vec<T>: UnsafeUnpin,
impl<T> UnwindSafe for Chunk<T>where
Vec<T>: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more