Skip to main content

Module hashing

Module hashing 

Source
Expand description

BLAKE3 Merkle tree construction, adaptive chunk sizing, and directory hashing. BLAKE3 hashing, Merkle tree, delta detection, directory hashing.

Structs§

ChunkHash
Per-chunk hash with file offset metadata.
DirHashAccumulator
Accumulates S3 restore child entries per directory prefix, producing a dir hash when finalize() is called for a given prefix.
DirtyRange
A contiguous byte range that differs between source and target.
MerkleSignature
Serializable Merkle signature for xattr/sidecar storage.
MerkleTree
BLAKE3 Merkle tree over fixed-size file chunks.

Enums§

ChecksumType
Checksum algorithm selection for sidecar file generation. BLAKE3 is FREE (reuses existing computation). Others require extra I/O.
ComputeMode
Controls which per-chunk computations MerkleTree::from_file() performs.

Constants§

CHUNK_SIZE
Keep backward compat for callers using CHUNK_SIZE directly
MAX_LEAVES_PER_XATTR
Max Merkle leaves per xattr – defined in constants.rs for central tuning.
MIN_CHUNK_SIZE
Minimum chunk size for Merkle tree – defined in constants.rs for central tuning.

Functions§

calculate_adaptive_chunk_size
Calculate chunk size for Merkle tree construction.
compute_dir_hash
Compute a directory hash from sorted child (name, hash) pairs. Uses BLAKE3 over concatenation of sorted name:hash entries. Provides a stable, order-independent directory fingerprint.
compute_dir_hash_from_path
Compute a directory hash by reading the directory at path. Each child’s metadata (size, mtime, type) is hashed, then all children are sorted by name and combined into a single BLAKE3 directory fingerprint. Skips foxing internal files (.foxing*, .foxing_meta sidecars).
compute_dir_hash_from_s3_children
Compute a directory hash from S3 child metadata.
get_lite_threshold_bytes
Get the current lite hash threshold in bytes
hash_buffer_full
Full BLAKE3 hash from an in-memory buffer (same algorithm as hash_file_full).
hash_buffer_lite
Lite hash from an in-memory buffer (head+tail sampling, same algorithm as hash_file_lite).
hash_file_checksum
Compute a hex-encoded checksum of a file using the specified algorithm.
hash_file_full
Compute a full BLAKE3 hash of an entire file.
hash_file_lite
Compute a fast BLAKE3 hash from the first and last 64KB of a file (head+tail sampling)
is_hashing_enabled
Check whether BLAKE3 hashing is currently enabled
log_crypto_capabilities
Log detected cryptographic hardware acceleration at startup. Called once during initialization to inform operators which hash algorithms benefit from hardware acceleration on this platform.
map_data_extents
Map allocated data extents in a file using SEEK_DATA/SEEK_HOLE. Returns Vec of (offset, length) pairs for data regions. Returns Err if the filesystem doesn’t support SEEK_HOLE.
set_hashing_enabled
Enable or disable BLAKE3 hashing globally
set_lite_threshold_kb
Set the minimum file size (in KB) for lite hash computation
shannon_entropy
Compute Shannon entropy of a byte slice, returning bits per symbol (0.0-8.0).
verify_incremental
Verify that src and dst have matching lite hashes (returns true if identical or below threshold)
verify_with_merkle
Compare a source file’s Merkle root against a stored signature.
write_checksum_files
Write checksum sidecar files next to a destination file. Format: GNU coreutils-compatible <hash> <filename>\n When cid_format is true and checksum type is BLAKE3, outputs CID base32lower instead of hex.