Struct toad_hash::Blake2Hasher
source · pub struct Blake2Hasher(_);
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 copy 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