Skip to main content

http_compress/xx_hash3_64/
struct.rs

1use super::*;
2
3/// A XXH3-64 hasher that keeps its secret on the stack.
4///
5/// The hasher `twox_hash` ships by default allocates its 192-byte secret on
6/// the heap, so every hash operation costs one allocation. A request that
7/// looks a header up in a map pays that allocation per lookup, which is why
8/// the allocating hasher is the single largest source of allocations on the
9/// request path.
10///
11/// This hasher keeps the same secret and produces the same hash values, but
12/// holds the secret in the hasher itself, so hashing allocates nothing.
13///
14/// # Examples
15///
16/// ```
17/// use http_compress::XxHash3_64;
18/// use std::hash::Hasher;
19///
20/// let mut hasher: XxHash3_64 = XxHash3_64::default();
21/// hasher.write(b"connection");
22/// let _: u64 = hasher.finish();
23/// ```
24#[derive(Clone)]
25pub struct XxHash3_64 {
26    /// The hasher that holds the secret, the seed and the buffer.
27    pub(super) inner: RawHasher<&'static [u8; DEFAULT_SECRET_LENGTH]>,
28}