chunk_diff/hasher/
xxhash.rs

1use twox_hash::XxHash64;
2
3const DEFAULT_SEED: u64 = 114514;
4
5pub struct XxHasher {
6    seed: u64,
7}
8
9impl super::Hasher for XxHasher {
10    fn hash(&self, data: &[u8]) -> u64 {
11        XxHash64::oneshot(self.seed, data)
12    }
13}
14
15impl Default for XxHasher {
16    fn default() -> Self {
17        Self { seed: DEFAULT_SEED }
18    }
19}
20
21impl XxHasher {
22    pub fn new(seed: u64) -> Self {
23        Self { seed }
24    }
25}