pub trait FastHash {
type Output: Copy + Eq + Debug + Default;
type Seed: Copy + Debug + Default;
const OUTPUT_SIZE: usize;
// Required method
fn hash_with_seed(seed: Self::Seed, data: &[u8]) -> Self::Output;
// Provided method
fn hash(data: &[u8]) -> Self::Output { ... }
}Expand description
A fast non-cryptographic hash.
These hashes are suitable for hash tables, sharding, fingerprints, and other non-adversarial settings. They are not suitable for signatures, MACs, password hashing, or untrusted inputs where collision attacks matter.
This trait is intentionally one-shot. Streaming APIs for fast hashes often require algorithm-specific buffering and are exposed as concrete types.
§Examples
let hash = MyHash::hash(b"hello world");
let seeded = MyHash::hash_with_seed(42, b"hello world");
assert_ne!(hash, seeded);Required Associated Constants§
Sourceconst OUTPUT_SIZE: usize
const OUTPUT_SIZE: usize
Output size in bytes.
Required Associated Types§
Required Methods§
Sourcefn hash_with_seed(seed: Self::Seed, data: &[u8]) -> Self::Output
fn hash_with_seed(seed: Self::Seed, data: &[u8]) -> Self::Output
Compute the hash of data using seed.
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementors§
Source§impl FastHash for RapidHash64
Available on (crate features sha2 or sha3 or blake2b or blake2s or blake3 or ascon-hash or xxh3 or rapidhash) and (crate features xxh3 or rapidhash) and crate feature rapidhash only.
impl FastHash for RapidHash64
Available on (crate features
sha2 or sha3 or blake2b or blake2s or blake3 or ascon-hash or xxh3 or rapidhash) and (crate features xxh3 or rapidhash) and crate feature rapidhash only.Source§impl FastHash for RapidHash128
Available on (crate features sha2 or sha3 or blake2b or blake2s or blake3 or ascon-hash or xxh3 or rapidhash) and (crate features xxh3 or rapidhash) and crate feature rapidhash only.
impl FastHash for RapidHash128
Available on (crate features
sha2 or sha3 or blake2b or blake2s or blake3 or ascon-hash or xxh3 or rapidhash) and (crate features xxh3 or rapidhash) and crate feature rapidhash only.Source§impl FastHash for RapidHashFast64
Available on (crate features sha2 or sha3 or blake2b or blake2s or blake3 or ascon-hash or xxh3 or rapidhash) and (crate features xxh3 or rapidhash) and crate feature rapidhash only.
impl FastHash for RapidHashFast64
Available on (crate features
sha2 or sha3 or blake2b or blake2s or blake3 or ascon-hash or xxh3 or rapidhash) and (crate features xxh3 or rapidhash) and crate feature rapidhash only.Source§impl FastHash for RapidHashFast128
Available on (crate features sha2 or sha3 or blake2b or blake2s or blake3 or ascon-hash or xxh3 or rapidhash) and (crate features xxh3 or rapidhash) and crate feature rapidhash only.
impl FastHash for RapidHashFast128
Available on (crate features
sha2 or sha3 or blake2b or blake2s or blake3 or ascon-hash or xxh3 or rapidhash) and (crate features xxh3 or rapidhash) and crate feature rapidhash only.