1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
use super::{NoiseDomain, helpers::{EmptyConfig, SeedOnlyNoise}};
use core::hash::{Hash, Hasher};
use wyhash::WyHash;
#[derive(Copy, Clone)]
pub struct HashNoise {
seed: u64,
}
impl HashNoise {
pub fn new() -> EmptyConfig<Self> {
EmptyConfig::new()
}
}
impl SeedOnlyNoise for HashNoise {
type Seed = u64;
type Value = u64;
fn seed(seed: u64) -> Self {
Self { seed }
}
}
impl<Arg: Hash> NoiseDomain<Arg> for HashNoise {
fn noise(&self, arg: Arg) -> u64 {
let mut hasher = WyHash::with_seed(self.seed);
arg.hash(&mut hasher);
hasher.finish()
}
}