-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
pub trait Hasher: Default { | ||
type Hash: Hash; | ||
fn write(&mut self, buf: &[u8]); | ||
fn finish(self) -> Self::Hash; | ||
} | ||
|
||
pub trait Hash: PartialEq + Eq + PartialOrd + Ord + Send + Sync + Copy {} | ||
|
||
impl<T> Hash for T where T: PartialEq + Eq + PartialOrd + Ord + Send + Sync + Copy {} | ||
|
||
impl Hasher for ahash::AHasher { | ||
Check failure on line 11 in src/hasher.rs
|
||
type Hash = u64; | ||
fn write(&mut self, buf: &[u8]) { | ||
std::hash::Hasher::write(self, buf); | ||
} | ||
fn finish(self) -> Self::Hash { | ||
std::hash::Hasher::finish(&self) | ||
} | ||
} | ||
|
||
impl Hasher for highway::HighwayHasher { | ||
Check failure on line 21 in src/hasher.rs
|
||
type Hash = [u64; 4]; | ||
fn write(&mut self, buf: &[u8]) { | ||
use highway::HighwayHash; | ||
Check failure on line 24 in src/hasher.rs
|
||
self.append(buf); | ||
} | ||
|
||
fn finish(self) -> Self::Hash { | ||
use highway::HighwayHash; | ||
Check failure on line 29 in src/hasher.rs
|
||
self.finalize256() | ||
} | ||
} | ||
|
||
impl Hasher for metrohash::MetroHash128 { | ||
Check failure on line 34 in src/hasher.rs
|
||
type Hash = (u64, u64); | ||
fn write(&mut self, buf: &[u8]) { | ||
std::hash::Hasher::write(self, buf); | ||
} | ||
|
||
fn finish(self) -> Self::Hash { | ||
self.finish128() | ||
} | ||
} | ||
|
||
impl Hasher for seahash::SeaHasher { | ||
Check failure on line 45 in src/hasher.rs
|
||
type Hash = u64; | ||
fn write(&mut self, buf: &[u8]) { | ||
std::hash::Hasher::write(self, buf); | ||
} | ||
fn finish(self) -> Self::Hash { | ||
std::hash::Hasher::finish(&self) | ||
} | ||
} | ||
|
||
impl Hasher for twox_hash::xxhash3_128::Hasher { | ||
Check failure on line 55 in src/hasher.rs
|
||
type Hash = u128; | ||
fn write(&mut self, buf: &[u8]) { | ||
self.write(buf); | ||
} | ||
|
||
fn finish(self) -> Self::Hash { | ||
self.finish_128() | ||
} | ||
} |