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: MetadataCidMetadata bundle CID
timestamp: u64Unix timestamp
message: StringCommit message
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
impl Commit
Sourcepub fn new(
parent: Option<CommitCid>,
metadata_bundle: MetadataCid,
timestamp: u64,
message: String,
) -> Self
pub fn new( parent: Option<CommitCid>, metadata_bundle: MetadataCid, timestamp: u64, message: String, ) -> Self
Creates a new unsigned commit with a single parent.
Sourcepub fn new_merge(
parents: Vec<CommitCid>,
metadata_bundle: MetadataCid,
timestamp: u64,
message: String,
) -> Self
pub fn new_merge( parents: Vec<CommitCid>, metadata_bundle: MetadataCid, timestamp: u64, message: String, ) -> Self
Creates a new unsigned merge commit with multiple parents.
Sourcepub fn is_initial(&self) -> bool
pub fn is_initial(&self) -> bool
Returns true if this is the initial commit (no parents).
Sourcepub fn first_parent(&self) -> Option<&CommitCid>
pub fn first_parent(&self) -> Option<&CommitCid>
Returns the first parent CID, if any.
Sourcepub fn referenced_object_cids(&self) -> Vec<VoidCid>
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.
Sourcepub fn signable_bytes(&self) -> Vec<u8> ⓘ
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
Sourcepub fn sign(&mut self, signing_key: &SigningKey)
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.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Commit
impl<'de> Deserialize<'de> for Commit
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for Commit
impl RefUnwindSafe for Commit
impl Send for Commit
impl Sync for Commit
impl Unpin for Commit
impl UnsafeUnpin for Commit
impl UnwindSafe for Commit
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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