use sp_std::vec::Vec; pub trait GhostHasher { type Hash: PartialEq + Copy + AsRef<[u8]> + AsMut<[u8]>; type HashBytes: AsRef<[u8]> + AsMut<[u8]> + TryFrom> + Default; fn from_slice(bytes: &[u8]) -> Self::Hash { let mut target_hash = Self::empty(); let hash_buffer = target_hash.as_mut(); let copy_len = bytes.len().min(hash_buffer.len()); hash_buffer[..copy_len].copy_from_slice(&bytes[..copy_len]); target_hash } fn hash_to_bytes(hash: Self::Hash) -> Self::HashBytes { let mut bytes = Self::HashBytes::default(); bytes.as_mut().copy_from_slice(hash.as_ref()); bytes } fn hash(data: &[u8]) -> Self::Hash; fn empty() -> Self::Hash; fn hash_len() -> usize; }