pub struct MerkleTree {
pub chunk_size: u64,
pub file_size: u64,
pub root: Hash,
pub leaves: Vec<ChunkHash>,
}Expand description
BLAKE3 Merkle tree over fixed-size file chunks.
Fields§
§chunk_size: u64Fixed chunk size used for this tree
file_size: u64Total file size at tree construction time
root: HashRoot hash computed from all leaf hashes
leaves: Vec<ChunkHash>Per-chunk hashes with offset metadata
Implementations§
Source§impl MerkleTree
impl MerkleTree
Sourcepub fn from_file(
path: &Path,
chunk_size: u64,
compute_mode: ComputeMode,
) -> Result<Self>
pub fn from_file( path: &Path, chunk_size: u64, compute_mode: ComputeMode, ) -> Result<Self>
Build a Merkle tree by hashing a file in fixed-size chunks.
Sourcepub fn diff(source: &MerkleTree, target: &MerkleTree) -> Vec<DirtyRange>
pub fn diff(source: &MerkleTree, target: &MerkleTree) -> Vec<DirtyRange>
Compare two Merkle trees and return ranges that differ. Adjacent dirty chunks are merged into contiguous ranges.
Sourcepub fn to_signature(&self) -> MerkleSignature
pub fn to_signature(&self) -> MerkleSignature
Convert to a serializable signature.
Sourcepub fn from_signature(sig: &MerkleSignature) -> Option<Self>
pub fn from_signature(sig: &MerkleSignature) -> Option<Self>
Reconstruct a MerkleTree from a stored signature.
Auto Trait Implementations§
impl Freeze for MerkleTree
impl RefUnwindSafe for MerkleTree
impl Send for MerkleTree
impl Sync for MerkleTree
impl Unpin for MerkleTree
impl UnsafeUnpin for MerkleTree
impl UnwindSafe for MerkleTree
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more