pub struct Hash { /* private fields */ }Expand description
Content hash, multihash-aware: a digest tagged with the function that
produced it. BLAKE3-256 today (32 bytes). The string form is <fn>:<hex>
(human-inspectable, the Display form); the binary
form (to_multihash_bytes) is a self-describing
multihash (uvarint(code) ++ uvarint(len) ++ digest).
Implementations§
Source§impl Hash
impl Hash
Sourcepub fn from_chunks<'a, I: IntoIterator<Item = &'a [u8]>>(chunks: I) -> Self
pub fn from_chunks<'a, I: IntoIterator<Item = &'a [u8]>>(chunks: I) -> Self
Compute the BLAKE3 hash by streaming chunks through the incremental hasher. Avoids materialising the full payload as a single contiguous slice — useful for verifying large model weights or other multi-MB blobs that arrive in chunks.
let hash = Hash::from_chunks([b"first ", b"second"].into_iter());
assert_eq!(hash, Hash::of(b"first second"));Sourcepub fn from_reader<R: Read>(reader: R) -> Result<Self>
pub fn from_reader<R: Read>(reader: R) -> Result<Self>
Compute the BLAKE3 hash by streaming bytes from a Read source —
e.g. a file handle or HTTP response body. Reads in 64 KiB chunks
until EOF.
This is the path that lets eidetic-side verification scale to
multi-GiB blobs without holding the full payload in memory at
once: pair it with a BlobFetcher that streams.
Sourcepub fn as_bytes(&self) -> &[u8; 32]
pub fn as_bytes(&self) -> &[u8; 32]
The raw digest bytes (no function tag). BLAKE3 is 32 bytes.
Sourcepub fn to_hex(&self) -> String
pub fn to_hex(&self) -> String
Hex-encoded digest (no algorithm prefix). For the self-describing form
use Display (<fn>:<hex>).
Sourcepub fn to_multihash_bytes(&self) -> Vec<u8> ⓘ
pub fn to_multihash_bytes(&self) -> Vec<u8> ⓘ
Self-describing binary multihash: uvarint(multicodec) ++ uvarint(len) ++ digest. Digest fields on the wire, in the event DAG, and in
capability scopes should use this form so a hash migration never needs a
flag day.
Sourcepub fn from_multihash_bytes(bytes: &[u8]) -> Result<Self, HashError>
pub fn from_multihash_bytes(bytes: &[u8]) -> Result<Self, HashError>
Parse a [Hash] from its self-describing binary multihash form.