axhash_core/hash/
build.rs1use core::hash::BuildHasher;
2
3use crate::constants::SECRET;
4
5use super::AxHasher;
6
7#[derive(Clone, Copy, Default)]
8pub struct AxBuildHasher {
9 pub(crate) prepared_seed: u64,
10}
11
12impl AxBuildHasher {
13 #[inline(always)]
14 pub const fn new() -> Self {
15 Self {
16 prepared_seed: SECRET[0],
17 }
18 }
19
20 #[inline(always)]
21 pub const fn with_seed(seed: u64) -> Self {
22 Self {
23 prepared_seed: seed ^ SECRET[0],
24 }
25 }
26}
27
28impl BuildHasher for AxBuildHasher {
29 type Hasher = AxHasher;
30
31 #[inline(always)]
32 fn build_hasher(&self) -> Self::Hasher {
33 AxHasher {
34 acc: self.prepared_seed,
35 sponge: 0,
36 sponge_bits: 0,
37 }
38 }
39}