pub struct CdbHash { /* private fields */ }Expand description
Implements the CDB hash function.
This hash function is a variant of DJB hash (Daniel J. Bernstein). It is used by CDB to distribute keys across hash tables.
§Examples
use std::hash::Hasher;
use cdb64::CdbHash;
let mut hasher = CdbHash::new();
hasher.write(b"some data");
let hash_value = hasher.finish();
println!("Hash: {}", hash_value);Implementations§
Trait Implementations§
Source§impl Hasher for CdbHash
impl Hasher for CdbHash
Source§fn write(&mut self, bytes: &[u8])
fn write(&mut self, bytes: &[u8])
The hash state is updated for each byte in the input slice according to the formula:
hash = ((hash << 5) + hash) ^ byte (using wrapping arithmetic).
Source§fn write_u64(&mut self, i: u64)
fn write_u64(&mut self, i: u64)
This is a convenience method that converts the u64 to its little-endian byte representation
and then calls write.
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 CdbHash
impl RefUnwindSafe for CdbHash
impl Send for CdbHash
impl Sync for CdbHash
impl Unpin for CdbHash
impl UnwindSafe for CdbHash
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