pub struct SliceHasher { /* private fields */ }Expand description
Incremental MD5 + CRC32 over one input slice, zero-padded to slice_size.
use rust_par2::slice::SliceHasher;
let mut h = SliceHasher::new(8);
h.update(b"abc");
h.update(b"de");
let sum = h.finish(); // checksums of b"abcde\0\0\0"
assert_eq!(sum, SliceHasher::checksum(b"abcde", 8));Implementations§
Source§impl SliceHasher
impl SliceHasher
Sourcepub fn new(slice_size: u64) -> Self
pub fn new(slice_size: u64) -> Self
Start hashing a slice of a set whose slice size is slice_size.
Sourcepub fn update(&mut self, data: &[u8])
pub fn update(&mut self, data: &[u8])
Feed the next bytes of the slice.
Bytes beyond slice_size are hashed too, so the result will not match
any IFSC entry; callers should not pass more than one slice.
Sourcepub fn finish(self) -> SliceChecksum
pub fn finish(self) -> SliceChecksum
Zero-pad to slice_size and return the checksum pair.
Sourcepub fn checksum(data: &[u8], slice_size: u64) -> SliceChecksum
pub fn checksum(data: &[u8], slice_size: u64) -> SliceChecksum
Checksum a whole slice in one call.
Auto Trait Implementations§
impl Freeze for SliceHasher
impl RefUnwindSafe for SliceHasher
impl Send for SliceHasher
impl Sync for SliceHasher
impl Unpin for SliceHasher
impl UnsafeUnpin for SliceHasher
impl UnwindSafe for SliceHasher
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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