pub enum Hasher {
CidRaw {
hasher: Sha256,
},
DagPb {
buffer: Vec<u8>,
leaves: Vec<DagNode>,
raw_leaves: bool,
},
}Expand description
A streaming hasher that accumulates data and produces a Cid on
finalization.
Variants§
CidRaw
CIDv1 with the raw codec: the whole input is one raw block.
DagPb
dag-pb DAG (CIDv0 wrapped leaves, or CIDv1 with raw leaves).
Implementations§
Source§impl Hasher
impl Hasher
Sourcepub fn for_ipfs() -> Self
pub fn for_ipfs() -> Self
Creates a hasher for IPFS CIDv0 dag-pb (wrapped leaves, balanced DAG).
Sourcepub fn for_ipfs_v1_raw_leaves() -> Self
pub fn for_ipfs_v1_raw_leaves() -> Self
Creates a hasher for IPFS CIDv1 dag-pb with raw leaves.
Matches kubo’s ipfs add --cid-version=1 --raw-leaves defaults: chunks
of 256 KiB are stored as raw blocks (codec 0x55) and the file root (if
the file spans multiple chunks) is a dag-pb node linking those raw leaves.
A single-chunk file collapses to a bare raw block whose CID is bafkrei….
Sourcepub fn for_expected(expected: &Cid) -> Result<Self, UnsupportedCid>
pub fn for_expected(expected: &Cid) -> Result<Self, UnsupportedCid>
Creates a hasher that reproduces the construction of the given CID: dag-pb with wrapped leaves for CIDv0, a single raw block for CIDv1 raw, dag-pb with raw leaves for CIDv1 dag-pb.