Expand description
A crate which defines two extensions:
HasherExt
trait which extends theHasher
trait.BuildHasherExt
trait which extends theBuildHasher
trait.
The purpose of these extensions is to allow the callers to compute sequences of hash values for any item that is hashable. This functionality is used in different algorithms such probabilistic data structures.
The [PairHasher
] implements the HasherExt
trait. It a combinator of two Hasher
instances which are used in order to generate the sequence of hash values.
The [PairHasherBuilder
] implements the BuildHasherExt
trait. It provides a convenient way to build [PairHasher
] instances. It also prives convenient new functions
which allow the user to create [PairHasher
] instances by combining two siphasher::sip::SipHasher
instances.
§Example
use aabel_multihash_rs::{BuildHasherExt, BuildPairHasher};
use std::hash::{BuildHasher, Hash};
let keys1 = (0, 0);
let keys2 = (1, 1);
let builder = BuildPairHasher::new_with_keys(keys1, keys2);
const HASHE_COUNT: usize = 10;
let item = "Hello world!";
let hashes = builder
.hashes_one(item)
.take(HASHE_COUNT)
.collect::<Vec<_>>();
assert_eq!(hashes.len(), HASHE_COUNT)
Structs§
- Build
Pair Hasher - An instance of
BuildHasher
trait which builds [PairHasher] instances. - Hash64
- Represents a u64 based hash value.
Traits§
- Build
Hasher Ext - Extends the
BuildHasher
trait by allowing to compute the sequence of hash values for one given hashable value. - Hasher
Ext - Extends the
Hasher
trait by providing a mechanism to get a sequence of hash values when the hashing operation is finalized.