pub struct ContentDigest(pub String);Expand description
A BLAKE3 content digest for idempotent deduplication.
The inner value is a 64-character hex string representing the BLAKE3 hash.
Tuple Fields§
§0: StringImplementations§
Source§impl ContentDigest
impl ContentDigest
Sourcepub fn compute_str(data: &str) -> Self
pub fn compute_str(data: &str) -> Self
Compute a BLAKE3 digest from a UTF-8 string.
Sourcepub fn compute_json<T: Serialize>(value: &T) -> Result<Self, DigestError>
pub fn compute_json<T: Serialize>(value: &T) -> Result<Self, DigestError>
Compute a digest from a JSON-serializable value using canonical serialization.
Canonical serialization means:
- JSON object key ordering is normalized recursively.
serde_json::to_string()(compact, no trailing whitespace).
For structured data with guaranteed field order (structs with named fields), serde_json produces deterministic output by default.
Sourcepub fn from_hex(hex: impl Into<String>) -> Result<Self, DigestError>
pub fn from_hex(hex: impl Into<String>) -> Result<Self, DigestError>
Create from a pre-computed hex string.
Validates that the string is exactly 64 hex characters.
Sourcepub fn from_hex_unchecked(hex: impl Into<String>) -> Self
pub fn from_hex_unchecked(hex: impl Into<String>) -> Self
Create from a pre-computed hex string without validation.
Use only when the digest is known to be valid (e.g. loaded from DB).
Trait Implementations§
Source§impl Clone for ContentDigest
impl Clone for ContentDigest
Source§fn clone(&self) -> ContentDigest
fn clone(&self) -> ContentDigest
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ContentDigest
impl Debug for ContentDigest
Source§impl<'de> Deserialize<'de> for ContentDigest
impl<'de> Deserialize<'de> for ContentDigest
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>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for ContentDigest
impl Display for ContentDigest
Source§impl Hash for ContentDigest
impl Hash for ContentDigest
Source§impl JsonSchema for ContentDigest
impl JsonSchema for ContentDigest
Source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
Whether JSON Schemas generated for this type should be re-used where possible using the
$ref keyword. Read moreSource§fn schema_name() -> String
fn schema_name() -> String
The name of the generated JSON Schema. Read more
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§impl Ord for ContentDigest
impl Ord for ContentDigest
Source§fn cmp(&self, other: &ContentDigest) -> Ordering
fn cmp(&self, other: &ContentDigest) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for ContentDigest
impl PartialEq for ContentDigest
Source§fn eq(&self, other: &ContentDigest) -> bool
fn eq(&self, other: &ContentDigest) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl PartialOrd for ContentDigest
impl PartialOrd for ContentDigest
Source§impl Serialize for ContentDigest
impl Serialize for ContentDigest
impl Eq for ContentDigest
impl StructuralPartialEq for ContentDigest
Auto Trait Implementations§
impl Freeze for ContentDigest
impl RefUnwindSafe for ContentDigest
impl Send for ContentDigest
impl Sync for ContentDigest
impl Unpin for ContentDigest
impl UnsafeUnpin for ContentDigest
impl UnwindSafe for ContentDigest
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
Mutably borrows from an owned value. Read more