pub(crate) fn stream_hash(
    stream: &mut impl Read,
    len: FileLen,
    buf_len: usize,
    progress: impl Fn(usize),
) -> io::Result<(FileLen, FileHash)> {
    let mut hasher = MetroHash128::new();
    let mut read_len: FileLen = FileLen(0);
    scan(stream, len, buf_len, |buf| {
        hasher.write(buf);
        read_len += FileLen(buf.len() as u64);
        (progress)(buf.len());
    })?;
    let (a, b) = hasher.finish128();
    Ok((read_len, FileHash(((a as u128) << 64) | b as u128)))
}
/// Computes the hash value over at most `len` bytes of the stream.
/// Returns the number of the bytes read and a 128-bit hash value.
Computes the hash value over at most `len` bytes of the stream.
Returns the number of the bytes read and a 128-bit hash value.
Computes the hash value over at most ` len ` bytes of the stream . Returns the number of the bytes read and a 128 - bit hash value .
pub(crate) fn stream_hash(
    stream: &mut impl Read,
    len: FileLen,
    buf_len: usize,
    progress: impl Fn(usize),
) -> io::Result<(FileLen, FileHash)> {
    let mut hasher = MetroHash128::new();
    let mut read_len: FileLen = FileLen(0);
    scan(stream, len, buf_len, |buf| {
        hasher.write(buf);
        read_len += FileLen(buf.len() as u64);
        (progress)(buf.len());
    })?;
    let (a, b) = hasher.finish128();
    Ok((read_len, FileHash(((a as u128) << 64) | b as u128)))
}
pub ( crate ) fn stream_hash ( stream : & mut impl Read , len : FileLen , buf_len : usize , progress : impl Fn ( usize ) , ) -> io :: Result < ( FileLen , FileHash ) > { let mut hasher = MetroHash128 :: new ( ) ; let mut read_len : FileLen = FileLen ( 0 ) ; scan ( stream , len , buf_len , | buf | { hasher . write ( buf ) ; read_len += FileLen ( buf . len ( ) as u64 ) ; ( progress ) ( buf . len ( ) ) ; } ) ? ; let ( a , b ) = hasher . finish128 ( ) ; Ok ( ( read_len , FileHash ( ( ( a as u128 ) << 64 ) | b as u128 ) ) ) }
Computes the hash value over at most `len` bytes of the stream.
Computes the hash value over at most ` len ` bytes of the stream .
stream
&mut impl Read
len
FileLen
buf_len
usize
progress
impl Fn(usize)
stream
&mut impl Read
len
FileLen
buf_len
usize
progress
impl Fn(usize)