Skip to main content

Commit

Struct Commit 

Source
pub struct Commit {
    pub parents: Vec<CommitCid>,
    pub metadata_bundle: MetadataCid,
    pub timestamp: u64,
    pub message: String,
    pub author: Option<SigningPubKey>,
    pub signature: Option<CommitSignature>,
    pub manifest_cid: Option<ManifestCid>,
    pub stats: Option<CommitStats>,
    pub repo_manifest_cid: Option<RepoManifestCid>,
}
Expand description

Commit object pointing to a metadata bundle.

Supports multiple parents for merge commits:

  • Empty parents: initial commit
  • One parent: normal commit
  • Two+ parents: merge commit

Optionally signed with Ed25519 for author verification.

Fields§

§parents: Vec<CommitCid>

Parent commit CIDs (empty for initial, 1 for normal, 2+ for merge)

§metadata_bundle: MetadataCid

Metadata bundle CID

§timestamp: u64

Unix timestamp

§message: String

Commit message

§author: Option<SigningPubKey>

Ed25519 public key of the author (None for unsigned commits)

§signature: Option<CommitSignature>

Ed25519 signature over signable_bytes() (None for unsigned commits)

§manifest_cid: Option<ManifestCid>

CID of TreeManifest (None if not present)

§stats: Option<CommitStats>

Quick stats for health verification (None if not present)

§repo_manifest_cid: Option<RepoManifestCid>

CID of encrypted repo manifest JSON (None for non-collab repos)

Implementations§

Source§

impl Commit

Source

pub fn new( parent: Option<CommitCid>, metadata_bundle: MetadataCid, timestamp: u64, message: String, ) -> Self

Creates a new unsigned commit with a single parent.

Source

pub fn new_merge( parents: Vec<CommitCid>, metadata_bundle: MetadataCid, timestamp: u64, message: String, ) -> Self

Creates a new unsigned merge commit with multiple parents.

Source

pub fn is_initial(&self) -> bool

Returns true if this is the initial commit (no parents).

Source

pub fn is_merge(&self) -> bool

Returns true if this is a merge commit (2+ parents).

Source

pub fn first_parent(&self) -> Option<&CommitCid>

Returns the first parent CID, if any.

Source

pub fn parent(&self) -> Option<&CommitCid>

Returns the single parent for non-merge commits.

Source

pub fn referenced_object_cids(&self) -> Vec<VoidCid>

All non-parent object CIDs referenced by this commit.

Returns parsed VoidCid for each referenced object (metadata bundle, tree manifest, repo manifest). This is the canonical list of objects a commit depends on — use it for reachability tracking to avoid missing objects when new CID fields are added to Commit.

Parent commit CIDs are excluded since they serve a different purpose (graph traversal vs. object reachability).

CIDs that fail to parse are silently skipped.

Source

pub fn is_signed(&self) -> bool

Returns true if this commit is signed.

Source

pub fn signable_bytes(&self) -> Vec<u8>

Returns the bytes to sign (excludes signature field).

Format: parents || metadata_bundle || timestamp || message || author || manifest_cid || stats || repo_manifest_cid

Source

pub fn sign(&mut self, signing_key: &SigningKey)

Sign the commit with an Ed25519 signing key.

Sets the author field to the public key and computes the signature.

Source

pub fn verify(&self) -> Result<bool>

Verify the commit signature.

Returns:

  • Ok(true) if the signature is valid
  • Ok(false) if the commit is unsigned (both author and signature are None)
  • Err(_) if the signature is invalid or malformed

Trait Implementations§

Source§

impl Clone for Commit

Source§

fn clone(&self) -> Commit

Returns a duplicate 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 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 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

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

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