pub struct ContentRef(/* private fields */);Expand description
An opaque, content-addressed reference to a stored blob.
Backed by a lowercase-hex BLAKE3 digest of the blob’s bytes: identical
content always produces the same ContentRef, so storing the same bytes
twice is a no-op after the first write. Callers must treat the value as
opaque — the backend, not the caller, decides how a ContentRef maps to
physical storage.
Deserialize is hand-written (below) to reject any string that is not 64
lowercase hex characters — a naive derive would let an unvalidated value
panic later in shard_path’s slicing.
See crates/khive-storage/docs/api/blob-store.md for the full rationale.
Implementations§
Source§impl ContentRef
impl ContentRef
Sourcepub fn from_hex(hex: impl Into<String>) -> Result<Self, String>
pub fn from_hex(hex: impl Into<String>) -> Result<Self, String>
Parse a ContentRef from a caller-supplied hex string.
Rejects anything that is not exactly 64 lowercase hex characters.
Uppercase is rejected (not normalized) to keep one canonical string
form per digest — see docs/api/blob-store.md.
Sourcepub fn from_digest_bytes(digest: &[u8; 32]) -> Self
pub fn from_digest_bytes(digest: &[u8; 32]) -> Self
Construct a ContentRef directly from a BLAKE3 digest’s raw bytes.
Trait Implementations§
Source§impl AsRef<str> for ContentRef
impl AsRef<str> for ContentRef
Source§impl Clone for ContentRef
impl Clone for ContentRef
Source§fn clone(&self) -> ContentRef
fn clone(&self) -> ContentRef
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more