Skip to main content

Commit

Struct Commit 

Source
pub struct Commit {
    pub format_version: u16,
    pub parents: Vec<ContentHash>,
    pub tree: BTreeMap<String, TreeEntry>,
    pub author: String,
    pub message: String,
    pub resolves: Option<ContentHash>,
}
Expand description

A content-addressed commit: parents, a path→entry tree, metadata.

Fields§

§format_version: u16

Wire-format version; see FORMAT_VERSION.

§parents: Vec<ContentHash>

Parent commit ids (0 = root, 2+ = merge).

§tree: BTreeMap<String, TreeEntry>

Path → entry, sorted (BTreeMap) so serialization is canonical.

§author: String

Author identity string (key-backed from L8 onward).

§message: String

Commit message.

§resolves: Option<ContentHash>

The commit whose TreeEntry::Conflict this commit resolves, when it is a resolution — resolution-as-linked-change, as metadata on the existing shape (DECISIONS.md D15: never a new merge substrate). A conflict is a value (invariant 6): the link points at the conflicted commit, which stays in history untouched. Additive (default + skip_serializing_if), so commits written before the field existed decode as None and re-serialize byte-identically — invariant 1.

Implementations§

Source§

impl Commit

Source

pub fn is_conflicted(&self) -> bool

Whether any tree entry is an unresolved TreeEntry::Conflict.

Source

pub fn validate_resolves(&self, store: &dyn ChunkStore) -> Result<(), ViewError>

Validates this commit’s resolves link against store.

A Some link must name a commit the store holds whose tree still carries an unresolved TreeEntry::Conflict — anything else is refused, never silently dropped: a dangling link admitted once would replay forever as a claim about a conflict nobody can load. None validates trivially (most commits resolve nothing).

§Errors

Returns ViewError::Resolution when the link is dangling or the referenced commit has no conflict to resolve.

Source

pub fn put(&self, store: &mut dyn ChunkStore) -> Result<ContentHash, ViewError>

Stores this commit in store and returns its content address.

§Errors

Propagates ViewError::Store from the underlying store.

Source

pub fn get(store: &dyn ChunkStore, id: &ContentHash) -> Result<Self, ViewError>

Loads the commit at id from store, verifying its address.

§Errors

Returns ViewError::Store on lookup/verification failure and ViewError::Decode when the bytes are not a commit.

Trait Implementations§

Source§

impl Clone for Commit

Source§

fn clone(&self) -> Commit

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 Debug for Commit

Source§

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

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

impl<'de> Deserialize<'de> for Commit

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Commit

Source§

fn eq(&self, other: &Commit) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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 Serialize for Commit

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for Commit

Source§

impl StructuralPartialEq for Commit

Auto Trait Implementations§

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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,