pub struct XxHash3_64 { /* private fields */ }Expand description
A XXH3-64 hasher that keeps its secret on the stack.
The hasher twox_hash ships by default allocates its 192-byte secret on
the heap, so every hash operation costs one allocation. A request that
looks a header up in a map pays that allocation per lookup, which is why
the allocating hasher is the single largest source of allocations on the
request path.
This hasher keeps the same secret and produces the same hash values, but holds the secret in the hasher itself, so hashing allocates nothing.
§Examples
use http_compress::XxHash3_64;
use std::hash::Hasher;
let mut hasher: XxHash3_64 = XxHash3_64::default();
hasher.write(b"connection");
let _: u64 = hasher.finish();Trait Implementations§
Source§impl Clone for XxHash3_64
Clone implementation for XxHash3_64.
impl Clone for XxHash3_64
Clone implementation for XxHash3_64.
Source§impl Default for XxHash3_64
Default construction for XxHash3_64.
impl Default for XxHash3_64
Default construction for XxHash3_64.
Source§impl Hasher for XxHash3_64
Implements impl core::hash::Hasher for XxHash3_64.
impl Hasher for XxHash3_64
Implements impl core::hash::Hasher for XxHash3_64.
Source§fn write(&mut self, bytes: &[u8])
fn write(&mut self, bytes: &[u8])
Feeds bytes into the same XXH3 stream while deferring large-state setup.
§Arguments
&[u8]- The bytes to hash.
Source§fn write_u8(&mut self, value: u8)
fn write_u8(&mut self, value: u8)
Feeds a single byte into the uninitialized prefix buffer without slice copy overhead.
§Arguments
u8- The byte to hash.
Source§fn finish(&self) -> u64
fn finish(&self) -> u64
Reports the same hash irrespective of write boundaries or prefix overflow.
§Returns
u64- The hash of all bytes written so far.
1.26.0 · Source§fn write_u128(&mut self, i: u128)
fn write_u128(&mut self, i: u128)
u128 into this hasher.1.3.0 · Source§fn write_usize(&mut self, i: usize)
fn write_usize(&mut self, i: usize)
usize into this hasher.1.26.0 · Source§fn write_i128(&mut self, i: i128)
fn write_i128(&mut self, i: i128)
i128 into this hasher.1.3.0 · Source§fn write_isize(&mut self, i: isize)
fn write_isize(&mut self, i: isize)
isize into this hasher.Source§fn write_length_prefix(&mut self, len: usize)
fn write_length_prefix(&mut self, len: usize)
hasher_prefixfree_extras)