use std::hash::{Hash, Hasher};
use seahash::SeaHasher;
use crate::cache_key::{CacheKey, CacheKeyHasher};
pub fn cache_digest<H: CacheKey>(hashable: &H) -> String {
fn cache_key_u64<H: CacheKey>(hashable: &H) -> u64 {
let mut hasher = CacheKeyHasher::new();
hashable.cache_key(&mut hasher);
hasher.finish()
}
to_hex(cache_key_u64(hashable))
}
pub fn hash_digest<H: Hash>(hashable: &H) -> String {
fn hash_u64<H: Hash>(hashable: &H) -> u64 {
let mut hasher = SeaHasher::new();
hashable.hash(&mut hasher);
hasher.finish()
}
to_hex(hash_u64(hashable))
}
fn to_hex(num: u64) -> String {
hex::encode(num.to_le_bytes())
}