Skip to main content

Module inner

Module inner 

Source
Expand description

In-memory hashing: RapidHasher with full configurability via compile-time arguments.

This module contains the Hasher, BuildHasher, HashMap, HashSet, and RandomState implementations. It is recommended to use crate::fast or crate::quality, but for the advanced user, crate::inner can be used directly to customise the compile time options to modify the hash function.

Each structure may have the compile time const generics:

  • AVALANCHE: Whether to use a final avalanche mix step, required to pass SMHasher3. This option changes the hash output. Enabled on crate::quality, disabled on crate::fast.
  • SPONGE: Allow RapidHasher to cache integers into a 128-bit buffer to perform a single folded multiply step on the entire buffer. If disabled, a mix step is performed on each individual integer. This changes the hash output when hashing integers. Enabled on both crate::quality and crate::fast.
  • COMPACT: Reduce the code size of the hasher by preventing manually unrolled loops. This does not affect the hash output. Disabled on both crate::quality and crate::fast.
  • PROTECTED: When performing the folded multiply mix step, XOR the a and b back into their original values to make it harder for an attacker to generate collisions. This changes the hash ouput. Disabled on both crate::quality and crate::fast.

The RapidHasher struct is inspired by rapidhash, but is not a direct port and will output different hash values. It keeps the same hasher quality but uses various optimisations to improve performance when used in the Rust Hasher trait.

The output values of functions in the inner module are not guaranteed to be stable between versions. Please use the v1, v2, or v3 modules for stable output values between rapidhash crate versions.

Structsยง

GlobalState
A BuildHasher that uses a global seed and secrets, randomized only once on startup.
RandomState
A [std::hash::RandomState] compatible hasher that initializes a RapidHasher with a random seed and random global secrets.
RapidHasher
A Hasher trait compatible hasher that uses the rapidhash algorithm, and uses #[inline(always)] for all methods.
SeedableState
A [std::hash::BuildHasher] that initializes a RapidHasher with a user-provided seed and secrets.