gix_diff::index

Enum ChangeRef

Source
pub enum ChangeRef<'lhs, 'rhs> {
    Addition {
        location: Cow<'rhs, BStr>,
        index: usize,
        entry_mode: Mode,
        id: Cow<'rhs, oid>,
    },
    Deletion {
        location: Cow<'lhs, BStr>,
        index: usize,
        entry_mode: Mode,
        id: Cow<'rhs, oid>,
    },
    Modification {
        location: Cow<'rhs, BStr>,
        previous_index: usize,
        previous_entry_mode: Mode,
        previous_id: Cow<'lhs, oid>,
        index: usize,
        entry_mode: Mode,
        id: Cow<'rhs, oid>,
    },
    Rewrite {
        source_location: Cow<'lhs, BStr>,
        source_index: usize,
        source_entry_mode: Mode,
        source_id: Cow<'lhs, oid>,
        location: Cow<'rhs, BStr>,
        index: usize,
        entry_mode: Mode,
        id: Cow<'rhs, oid>,
        copy: bool,
    },
}
Available on crate feature index only.
Expand description

Identify a change that would have to be applied to lhs to obtain rhs, as provided in index().

Variants§

§

Addition

An entry was added to rhs.

Fields

§location: Cow<'rhs, BStr>

The location of the newly added entry in rhs.

§index: usize

The index into the entries array of rhs for full access.

§entry_mode: Mode

The mode of the entry in rhs.

§id: Cow<'rhs, oid>

The object id of the entry in rhs.

§

Deletion

An entry was removed from rhs.

Fields

§location: Cow<'lhs, BStr>

The location the entry that doesn’t exist in rhs.

§index: usize

The index into the entries array of lhs for full access.

§entry_mode: Mode

The mode of the entry in lhs.

§id: Cow<'rhs, oid>

The object id of the entry in lhs.

§

Modification

An entry was modified, i.e. has changed its content or its mode.

Fields

§location: Cow<'rhs, BStr>

The location of the modified entry both in lhs and rhs.

§previous_index: usize

The index into the entries array of lhs for full access.

§previous_entry_mode: Mode

The previous mode of the entry, in lhs.

§previous_id: Cow<'lhs, oid>

The previous object id of the entry, in lhs.

§index: usize

The index into the entries array of rhs for full access.

§entry_mode: Mode

The mode of the entry in rhs.

§id: Cow<'rhs, oid>

The object id of the entry in rhs.

§

Rewrite

An entry was renamed or copied from lhs to rhs.

A rename is effectively fusing together the Deletion of the source and the Addition of the destination.

Fields

§source_location: Cow<'lhs, BStr>

The location of the source of the rename or copy operation, in lhs.

§source_index: usize

The index of the entry before the rename, into the entries array of rhs for full access.

§source_entry_mode: Mode

The mode of the entry before the rewrite, in lhs.

§source_id: Cow<'lhs, oid>

The object id of the entry before the rewrite.

Note that this is the same as id if we require the similarity to be 100%, but may be different otherwise.

§location: Cow<'rhs, BStr>

The current location of the entry in rhs.

§index: usize

The index of the entry after the rename, into the entries array of rhs for full access.

§entry_mode: Mode

The mode of the entry after the rename in rhs.

§id: Cow<'rhs, oid>

The object id of the entry after the rename in rhs.

§copy: bool

If true, this rewrite is created by copy, and source_id is pointing to its source. Otherwise, it’s a rename, and source_id points to a deleted object, as renames are tracked as deletions and additions of the same or similar content.

Implementations§

Source§

impl ChangeRef<'_, '_>

Source

pub fn into_owned(self) -> Change

Copy everything into an owned version of this instance.

Source§

impl ChangeRef<'_, '_>

Source

pub fn fields(&self) -> (&BStr, usize, Mode, &oid)

Return all shared fields among all variants: (location, index, entry_mode, id)

In case of rewrites, the fields return to the current change.

Trait Implementations§

Source§

impl Change for ChangeRef<'_, '_>

Source§

fn id(&self) -> &oid

Available on crate feature blob only.
Return the hash of the object behind this change for identification. Read more
Source§

fn relation(&self) -> Option<Relation>

Available on crate feature blob only.
Return the relation that this change may have with other changes. Read more
Source§

fn kind(&self) -> ChangeKind

Available on crate feature blob only.
Return the kind of this change.
Source§

fn entry_mode(&self) -> EntryMode

Available on crate feature blob only.
Return more information about the kind of entry affected by this change.
Source§

fn id_and_entry_mode(&self) -> (&oid, EntryMode)

Available on crate feature blob only.
Return the id of the change along with its mode.
Source§

impl<'lhs, 'rhs> Clone for ChangeRef<'lhs, 'rhs>

Source§

fn clone(&self) -> ChangeRef<'lhs, 'rhs>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'lhs, 'rhs> Debug for ChangeRef<'lhs, 'rhs>

Source§

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

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

impl<'lhs, 'rhs> PartialEq for ChangeRef<'lhs, 'rhs>

Source§

fn eq(&self, other: &ChangeRef<'lhs, 'rhs>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'lhs, 'rhs> Eq for ChangeRef<'lhs, 'rhs>

Source§

impl<'lhs, 'rhs> StructuralPartialEq for ChangeRef<'lhs, 'rhs>

Auto Trait Implementations§

§

impl<'lhs, 'rhs> Freeze for ChangeRef<'lhs, 'rhs>

§

impl<'lhs, 'rhs> RefUnwindSafe for ChangeRef<'lhs, 'rhs>

§

impl<'lhs, 'rhs> Send for ChangeRef<'lhs, 'rhs>

§

impl<'lhs, 'rhs> Sync for ChangeRef<'lhs, 'rhs>

§

impl<'lhs, 'rhs> Unpin for ChangeRef<'lhs, 'rhs>

§

impl<'lhs, 'rhs> UnwindSafe for ChangeRef<'lhs, 'rhs>

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, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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.