pub struct DiffDocument {
pub commit: Option<CommitHeader>,
pub files: Vec<FileDiff>,
}Expand description
A complete unified diff document.
Fields§
§commit: Option<CommitHeader>Commit preamble before the first diff --git section, if present.
files: Vec<FileDiff>File diffs in input order.
Implementations§
Source§impl DiffDocument
impl DiffDocument
Source§impl DiffDocument
impl DiffDocument
Sourcepub fn for_hunks(file: &FileDiff, hunks: impl IntoIterator<Item = Hunk>) -> Self
pub fn for_hunks(file: &FileDiff, hunks: impl IntoIterator<Item = Hunk>) -> Self
Returns a single-file document with the given hunks, suitable for
git apply. The preamble is dropped.
Sourcepub fn split_hunks(self) -> Self
pub fn split_hunks(self) -> Self
Splits multi-change hunks into independently reviewable hunks.
Hunk ids are reassigned sequentially across the whole document, so the split must run before any per-hunk state is derived for pieces to keep stable identities across reloads.
Trait Implementations§
Source§impl Clone for DiffDocument
impl Clone for DiffDocument
Source§impl Debug for DiffDocument
impl Debug for DiffDocument
Source§impl Decode for DiffDocument
impl Decode for DiffDocument
Source§fn decode(input: &mut impl BufRead) -> Result<Self, DecodeError>
fn decode(input: &mut impl BufRead) -> Result<Self, DecodeError>
Reads a full diff document from the input stream.
Source§fn decode_bytes(input: &[u8]) -> Result<Self, DecodeError>
fn decode_bytes(input: &[u8]) -> Result<Self, DecodeError>
Decodes a diff document from raw bytes.
Non-UTF-8 bytes are replaced with U+FFFD and ANSI escape sequences are stripped before parsing, so output from colored Git pipes round-trips without caller-side preprocessing.
Source§fn try_decode(input: &mut impl BufRead) -> Result<Option<Self>, DecodeError>
fn try_decode(input: &mut impl BufRead) -> Result<Option<Self>, DecodeError>
Reads and decodes a value, returning
Ok(None) at clean end-of-input.
Anything else, including a partial value followed by EOF surfaces as
Err.Source§fn decode_str(input: &str) -> Result<Self, DecodeError>
fn decode_str(input: &str) -> Result<Self, DecodeError>
Decodes a value from a UTF-8 string.
Source§impl Default for DiffDocument
impl Default for DiffDocument
Source§impl Encode for DiffDocument
impl Encode for DiffDocument
impl Eq for DiffDocument
Source§impl PartialEq for DiffDocument
impl PartialEq for DiffDocument
impl StructuralPartialEq for DiffDocument
Auto Trait Implementations§
impl Freeze for DiffDocument
impl RefUnwindSafe for DiffDocument
impl Send for DiffDocument
impl Sync for DiffDocument
impl Unpin for DiffDocument
impl UnsafeUnpin for DiffDocument
impl UnwindSafe for DiffDocument
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