xxhash-rust
Pure-Rust implementation of the XXH32, XXH64, and XXH3 hash algorithms
Repository Health
Technical Analysis
xxhash-rust is a from-scratch, pure-Rust reimplementation of the xxHash family of non-cryptographic hash algorithms (XXH32, XXH64, and the newer XXH3), used for fast checksumming, hash-map keys, and content-addressing where cryptographic security isn’t required. Unlike bindings that link against the C xxHash library, this crate is written entirely in Rust with no C dependency, and supports no_std environments (with an optional alloc-free mode) for embedded and constrained targets.
Each algorithm variant is feature-gated (xxh32, xxh64, xxh3) so consumers only compile the hash functions they actually use, and const-context variants (const_xxh32, const_xxh64, const_xxh3) allow computing hashes at compile time. It’s a widely-depended-on building block across the Rust ecosystem for fast hashing where allocation-free, no-std-compatible code is required.
What You Get
- Pure-Rust implementations of XXH32, XXH64, and XXH3 with no C library dependency
- Feature-gated compilation (
xxh32,xxh64,xxh3) so you only build the variants you actually use no_stdsupport, including a no-allocation mode suitable for embedded and constrained environments- Const-context hashing (
const_xxh32,const_xxh64,const_xxh3) for computing hashes at compile time - Optional
std::io::Writeimplementation (via thestdfeature) for streaming hash computation over readers/writers
Common Use Cases
- Fast, non-cryptographic checksumming of files or network payloads where speed matters more than cryptographic security
- Hashing keys for high-performance hash maps/sets that don’t need collision-resistance guarantees
- Compile-time hash computation (e.g. for perfect hash tables or static lookup keys) via the const-context variants
- Content-addressing or deduplication in no_std embedded firmware where a C xxHash dependency isn’t viable
- Cache-key generation for build tools and asset pipelines needing a fast, stable hash of file contents
Under The Hood
Architecture - The crate is organized as one Rust module per algorithm variant: xxh32.rs, xxh64.rs, and the larger xxh3.rs (~1,640 lines, the most complex due to XXH3’s SIMD-friendly design and secret/seed handling), each paired with a const_* sibling module implementing the same algorithm in a const fn-compatible style for compile-time evaluation; shared constants and utility bit-manipulation helpers live in *_common.rs and utils.rs. Tech Stack - Pure Rust (2018 edition) with zero mandatory dependencies; the crate is entirely no_std-compatible with an additional no-allocation mode, and dev-dependencies include xxhash-c-sys (the official C bindings) purely to cross-validate output correctness against the reference implementation in tests. Code Quality - Correctness is validated with 4 integration test files that compare this pure-Rust implementation’s output byte-for-byte against the canonical C xxHash library via xxhash-c-sys, plus a valgrind.supp suppression file indicating the maintainer runs memory-safety tooling in CI. API Design - The API mirrors Rust’s standard hashing conventions (implementing core::hash::Hasher where applicable) while also exposing simple one-shot functions (e.g. xxh3::xxh3_64(bytes)) for the common case, so consumers can pick either the streaming Hasher trait or a direct function call depending on their use case.
Used by 4 apps in this directory
Arroyo
Data Engineering · Analytics
A distributed stream processing engine written in Rust that lets you write SQL to run stateful, real-time computations over data streams with subsecond results.
Fluree DB
Databases
A temporal, verifiable graph database with git-like branching, integrated vector/text/geo search, and RDF/SPARQL/JSON-LD/openCypher support — benchmarked at 10.4x faster than the next database on the full Wikidata dump.
QuestDB
Databases · Analytics
A high-performance, open-source time-series database built for financial market data, IoT telemetry, and real-time analytics, combining a zero-GC Java/C++ core with SIMD-accelerated SQL and a WAL-to-Parquet storage engine.
Stalwart
Collaboration
All-in-one secure mail and collaboration server covering IMAP, JMAP, SMTP, CalDAV, CardDAV, and WebDAV in a single memory-safe Rust binary.