pub struct Patch<'buffers> { /* private fields */ }
Expand description
A structure representing the text changes in a single diff delta.
This is an opaque structure.
Implementations
sourceimpl<'buffers> Patch<'buffers>
impl<'buffers> Patch<'buffers>
sourcepub fn from_diff(
diff: &Diff<'buffers>,
idx: usize
) -> Result<Option<Self>, Error>
pub fn from_diff(
diff: &Diff<'buffers>,
idx: usize
) -> Result<Option<Self>, Error>
Return a Patch for one file in a Diff.
Returns Ok(None) for an unchanged or binary file.
sourcepub fn from_blobs(
old_blob: &Blob<'buffers>,
old_path: Option<&Path>,
new_blob: &Blob<'buffers>,
new_path: Option<&Path>,
opts: Option<&mut DiffOptions>
) -> Result<Self, Error>
pub fn from_blobs(
old_blob: &Blob<'buffers>,
old_path: Option<&Path>,
new_blob: &Blob<'buffers>,
new_path: Option<&Path>,
opts: Option<&mut DiffOptions>
) -> Result<Self, Error>
Generate a Patch by diffing two blobs.
sourcepub fn from_blob_and_buffer(
old_blob: &Blob<'buffers>,
old_path: Option<&Path>,
new_buffer: &'buffers [u8],
new_path: Option<&Path>,
opts: Option<&mut DiffOptions>
) -> Result<Self, Error>
pub fn from_blob_and_buffer(
old_blob: &Blob<'buffers>,
old_path: Option<&Path>,
new_buffer: &'buffers [u8],
new_path: Option<&Path>,
opts: Option<&mut DiffOptions>
) -> Result<Self, Error>
Generate a Patch by diffing a blob and a buffer.
sourcepub fn from_buffers(
old_buffer: &'buffers [u8],
old_path: Option<&Path>,
new_buffer: &'buffers [u8],
new_path: Option<&Path>,
opts: Option<&mut DiffOptions>
) -> Result<Self, Error>
pub fn from_buffers(
old_buffer: &'buffers [u8],
old_path: Option<&Path>,
new_buffer: &'buffers [u8],
new_path: Option<&Path>,
opts: Option<&mut DiffOptions>
) -> Result<Self, Error>
Generate a Patch by diffing two buffers.
sourcepub fn line_stats(&self) -> Result<(usize, usize, usize), Error>
pub fn line_stats(&self) -> Result<(usize, usize, usize), Error>
Get the number of lines of context, additions, and deletions in the Patch.
sourcepub fn hunk(&self, hunk_idx: usize) -> Result<(DiffHunk<'buffers>, usize), Error>
pub fn hunk(&self, hunk_idx: usize) -> Result<(DiffHunk<'buffers>, usize), Error>
Get a DiffHunk and its total line count from the Patch.
sourcepub fn num_lines_in_hunk(&self, hunk_idx: usize) -> Result<usize, Error>
pub fn num_lines_in_hunk(&self, hunk_idx: usize) -> Result<usize, Error>
Get the number of lines in a hunk.
sourcepub fn line_in_hunk(
&self,
hunk_idx: usize,
line_of_hunk: usize
) -> Result<DiffLine<'buffers>, Error>
pub fn line_in_hunk(
&self,
hunk_idx: usize,
line_of_hunk: usize
) -> Result<DiffLine<'buffers>, Error>
Get a DiffLine from a hunk of the Patch.
sourcepub fn size(
&self,
include_context: bool,
include_hunk_headers: bool,
include_file_headers: bool
) -> usize
pub fn size(
&self,
include_context: bool,
include_hunk_headers: bool,
include_file_headers: bool
) -> usize
Get the size of a Patch’s diff data in bytes.
Trait Implementations
impl<'buffers> Send for Patch<'buffers>
Auto Trait Implementations
impl<'buffers> RefUnwindSafe for Patch<'buffers>
impl<'buffers> !Sync for Patch<'buffers>
impl<'buffers> Unpin for Patch<'buffers>
impl<'buffers> UnwindSafe for Patch<'buffers>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more