Skip to main content

GitPatchRecord

Enum GitPatchRecord 

Source
pub enum GitPatchRecord<'a> {
    File {
        st: u8,
        similarity: u8,
        flags: u8,
        old_path: &'a str,
        new_path: &'a str,
    },
    Row {
        old_line: u32,
        new_line: u32,
        old_text: &'a [u8],
        new_text: &'a [u8],
        old_spans: Vec<(u32, u32)>,
        new_spans: Vec<(u32, u32)>,
    },
    Gap {
        old_line: u32,
        new_line: u32,
    },
    Base {
        oid: GitOid,
    },
    Cursor {
        after: &'a str,
        pos: u64,
    },
}
Expand description

One decoded record from a structured GIT_PATCH response payload.

Variants§

§

File

PATCH_FILE 0x01: [kind:1][st:1][similarity:1][flags:1] [old_len:2][old_path:N][new_len:2][new_path:N] Begins a file section. st/similarity lead, mirroring DIFF_ENTRY field for field, so a consumer has one status alphabet and one field order across both views — and so a binary or empty added file, which emits no rows at all, still says whether it was added, deleted or modified. old_path carries the old path whenever there is one, not only for renames.

Fields

§st: u8
§similarity: u8
§flags: u8
§old_path: &'a str
§new_path: &'a str
§

Row

PATCH_ROW 0x02: [kind:1][old_line:4][new_line:4] [old_text_len:4][old_text:N][new_text_len:4][new_text:N] [n_old_spans:2][spans:(start:4,len:4)·N][n_new_spans:2][spans:(start:4,len:4)·N] Line numbers are 1-based; 0 = side absent (pure addition/deletion). Text is the side’s true bytes; spans are byte ranges within it.

Fields

§old_line: u32
§new_line: u32
§old_text: &'a [u8]
§new_text: &'a [u8]
§old_spans: Vec<(u32, u32)>
§new_spans: Vec<(u32, u32)>
§

Gap

PATCH_GAP 0x03: [kind:1][old_line:4][new_line:4] Elision between hunks (the “@@” of a unified diff).

Fields

§old_line: u32
§new_line: u32
§

Base

BASE 0x04: [kind:1][oid:32] — as in GIT_DIFF.

Fields

§

Cursor

CURSOR 0x7F: continue with after/pos as the request’s after/after_pos, so a file past the byte budget resumes mid-hunk rather than restarting.

Fields

§after: &'a str
§pos: u64

Trait Implementations§

Source§

impl<'a> Clone for GitPatchRecord<'a>

Source§

fn clone(&self) -> GitPatchRecord<'a>

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<'a> Debug for GitPatchRecord<'a>

Source§

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

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

impl<'a> Eq for GitPatchRecord<'a>

Source§

impl<'a> PartialEq for GitPatchRecord<'a>

Source§

fn eq(&self, other: &GitPatchRecord<'a>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<'a> StructuralPartialEq for GitPatchRecord<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for GitPatchRecord<'a>

§

impl<'a> RefUnwindSafe for GitPatchRecord<'a>

§

impl<'a> Send for GitPatchRecord<'a>

§

impl<'a> Sync for GitPatchRecord<'a>

§

impl<'a> Unpin for GitPatchRecord<'a>

§

impl<'a> UnsafeUnpin for GitPatchRecord<'a>

§

impl<'a> UnwindSafe for GitPatchRecord<'a>

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.