Skip to content

Commit 8bf77a6

Browse files
committed
Switch to foldhash-portable and add generic BuildHasher support
- Replace xxhash-rust with foldhash-portable (portable feature) - Add S: BuildHasher generic parameter to Filter and Builder - Add _with_hasher constructors and with_hasher() for swapping hashers - Document T: Hash stability caveats and custom hasher usage - Update tests for new hash algorithm
1 parent e5a9982 commit 8bf77a6

File tree

4 files changed

+353
-79
lines changed

4 files changed

+353
-79
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jsonschema = ["schemars"]
1919
serde = ["dep:serde", "dep:serde_bytes"]
2020

2121
[dependencies]
22-
xxhash-rust = { version = "0.8.12", features = ["xxh3"] }
22+
foldhash-portable = { version = "0.2.0", features = ["portable"] }
2323
serde = { optional = true, version = "1", features = ["derive"] }
2424
serde_bytes = { optional = true, version = "0.11" }
2525
schemars = { optional = true, version = "1" }

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ for i in 0..1000 {
4242

4343
### Hasher
4444

45-
The hashing algorithm used is [xxhash3](https://crates.io/crates/xxhash-rust) which offers both high performance and stability across platforms.
45+
Methods accepting `T: Hash` are provided for convenience using [foldhash-portable](https://crates.io/crates/foldhash-portable), which offers high performance and stability across platforms. Note that a fixed seed is used (no DoS resistance) and `#[derive(Hash)]` output is [not guaranteed stable](https://github.com/hoxxep/portable-hash#whats-wrong-with-the-stdhash-traits) across Rust compiler versions.
46+
47+
`Filter` supports a custom `BuildHasher` via its `S` type parameter (similar to `HashMap`). Use `Filter::new_with_hasher()` and related constructors. The hasher is not serialized (reconstructed via `S: Default`), and filters being merged must use the same hasher.
4648

4749
### Filter size
4850

0 commit comments

Comments
 (0)