pub struct Blake2Hasher(/* private fields */);Expand description
Heap-allocless Hasher implementation that uses
the blake2 algo to generate a 64 bit hash.
use core::hash::{Hash, Hasher};
use toad_hash::Blake2Hasher;
let mut hasher_a = Blake2Hasher::new();
let mut hasher_b = Blake2Hasher::new();
let bytes = core::iter::repeat(0u8..255).take(512)
.flatten()
.collect::<Vec<u8>>();
bytes.hash(&mut hasher_a);
bytes.hash(&mut hasher_b);
assert_eq!(hasher_a.finish(), hasher_b.finish());
"hello".hash(&mut hasher_a);
"hello".hash(&mut hasher_b);
assert_eq!(hasher_a.finish(), hasher_b.finish());
123_u16.hash(&mut hasher_a);
"not 123!".hash(&mut hasher_b);
assert_ne!(hasher_a.finish(), hasher_b.finish());Implementations§
Source§impl Blake2Hasher
impl Blake2Hasher
Trait Implementations§
Source§impl Clone for Blake2Hasher
impl Clone for Blake2Hasher
Source§fn clone(&self) -> Blake2Hasher
fn clone(&self) -> Blake2Hasher
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Blake2Hasher
impl Debug for Blake2Hasher
Source§impl Default for Blake2Hasher
impl Default for Blake2Hasher
Source§fn default() -> Blake2Hasher
fn default() -> Blake2Hasher
Returns the “default value” for a type. Read more
Source§impl Hasher for Blake2Hasher
impl Hasher for Blake2Hasher
1.26.0 · Source§fn write_u128(&mut self, i: u128)
fn write_u128(&mut self, i: u128)
Writes a single
u128 into this hasher.1.3.0 · Source§fn write_usize(&mut self, i: usize)
fn write_usize(&mut self, i: usize)
Writes a single
usize into this hasher.1.26.0 · Source§fn write_i128(&mut self, i: i128)
fn write_i128(&mut self, i: i128)
Writes a single
i128 into this hasher.1.3.0 · Source§fn write_isize(&mut self, i: isize)
fn write_isize(&mut self, i: isize)
Writes a single
isize into this hasher.Source§fn write_length_prefix(&mut self, len: usize)
fn write_length_prefix(&mut self, len: usize)
🔬This is a nightly-only experimental API. (
hasher_prefixfree_extras)Writes a length prefix into this hasher, as part of being prefix-free. Read more
Auto Trait Implementations§
impl Freeze for Blake2Hasher
impl RefUnwindSafe for Blake2Hasher
impl Send for Blake2Hasher
impl Sync for Blake2Hasher
impl Unpin for Blake2Hasher
impl UnwindSafe for Blake2Hasher
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