Skip to main content

loonfs_core/commit/
identity.rs

1//! Commit identity fingerprints (format spec, "Commit identity
2//! fingerprints"): a stable digest over a mutation's semantic content, used
3//! to decide whether a reused commit id carries the same mutation or a
4//! conflicting one.
5//!
6//! The digest itself is computed by
7//! [`loonfs_api::semantic_commit_fingerprint`], because the HTTP client has
8//! to compute the same value and does not depend on this crate. What stays
9//! here is core's name for one: a value that reached this crate through
10//! [`crate::path::write::commit_fingerprint`] and is therefore comparable
11//! against a stored receipt.
12
13use serde::{Deserialize, Serialize};
14
15/// The semantic identity of one mutation request: what a reused commit id is
16/// compared against.
17#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
18pub struct CommitFingerprint(String);
19
20impl CommitFingerprint {
21    pub(crate) fn new_unchecked(value: String) -> Self {
22        Self(value)
23    }
24
25    pub fn as_str(&self) -> &str {
26        &self.0
27    }
28}