[−][src]Struct git2::Patch
A structure representing the text changes in a single diff delta.
This is an opaque structure.
Methods
impl Patch
[src]
pub fn from_diff(diff: &Diff, idx: usize) -> Result<Option<Patch>, Error>
[src]
Return a Patch for one file in a Diff.
Returns Ok(None) for an unchanged or binary file.
pub fn from_blobs(
old_blob: &Blob,
old_path: Option<&Path>,
new_blob: &Blob,
new_path: Option<&Path>,
opts: Option<&mut DiffOptions>
) -> Result<Patch, Error>
[src]
old_blob: &Blob,
old_path: Option<&Path>,
new_blob: &Blob,
new_path: Option<&Path>,
opts: Option<&mut DiffOptions>
) -> Result<Patch, Error>
Generate a Patch by diffing two blobs.
pub fn from_blob_and_buffer(
old_blob: &Blob,
old_path: Option<&Path>,
new_buffer: &[u8],
new_path: Option<&Path>,
opts: Option<&mut DiffOptions>
) -> Result<Patch, Error>
[src]
old_blob: &Blob,
old_path: Option<&Path>,
new_buffer: &[u8],
new_path: Option<&Path>,
opts: Option<&mut DiffOptions>
) -> Result<Patch, Error>
Generate a Patch by diffing a blob and a buffer.
pub fn from_buffers(
old_buffer: &[u8],
old_path: Option<&Path>,
new_buffer: &[u8],
new_path: Option<&Path>,
opts: Option<&mut DiffOptions>
) -> Result<Patch, Error>
[src]
old_buffer: &[u8],
old_path: Option<&Path>,
new_buffer: &[u8],
new_path: Option<&Path>,
opts: Option<&mut DiffOptions>
) -> Result<Patch, Error>
Generate a Patch by diffing two buffers.
pub fn delta(&self) -> DiffDelta
[src]
Get the DiffDelta associated with the Patch.
pub fn num_hunks(&self) -> usize
[src]
Get the number of hunks in the Patch.
pub fn line_stats(&self) -> Result<(usize, usize, usize), Error>
[src]
Get the number of lines of context, additions, and deletions in the Patch.
pub fn hunk(&self, hunk_idx: usize) -> Result<(DiffHunk, usize), Error>
[src]
Get a DiffHunk and its total line count from the Patch.
pub fn num_lines_in_hunk(&self, hunk_idx: usize) -> Result<usize, Error>
[src]
Get the number of lines in a hunk.
pub fn line_in_hunk(
&self,
hunk_idx: usize,
line_of_hunk: usize
) -> Result<DiffLine, Error>
[src]
&self,
hunk_idx: usize,
line_of_hunk: usize
) -> Result<DiffLine, Error>
Get a DiffLine from a hunk of the Patch.
pub fn size(
&self,
include_context: bool,
include_hunk_headers: bool,
include_file_headers: bool
) -> usize
[src]
&self,
include_context: bool,
include_hunk_headers: bool,
include_file_headers: bool
) -> usize
Get the size of a Patch's diff data in bytes.
pub fn print(
&mut self,
line_cb: &mut (dyn FnMut(DiffDelta, Option<DiffHunk>, DiffLine) -> bool + 'a)
) -> Result<(), Error>
[src]
&mut self,
line_cb: &mut (dyn FnMut(DiffDelta, Option<DiffHunk>, DiffLine) -> bool + 'a)
) -> Result<(), Error>
Print the Patch to text via a callback.
pub fn to_buf(&mut self) -> Result<Buf, Error>
[src]
Get the Patch text as a Buf.
Trait Implementations
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,