#![cfg_attr(not(feature = "std"), no_std)]
#[cfg(feature = "std")]
extern crate core;
#[cfg(feature = "std")]
#[cfg(feature = "std")]
use std::collections::HashMap;
use core::{fmt::Debug, hash::Hash};
pub trait Hasher: Sync + Send {
type Out: AsRef<[u8]> + AsMut<[u8]> + Default + Debug + PartialEq + Eq + Hash + Send + Sync + Clone + Copy;
type StdHasher: Sync + Send + Default + core::hash::Hasher;
const LENGTH: usize;
fn hash(x: &[u8]) -> Self::Out;
}
#[cfg(feature = "std")]
pub trait HashDB<H: Hasher, T>: Send + Sync + AsHashDB<H, T> {
fn keys(&self) -> HashMap<H::Out, i32>;
fn get(&self, key: &H::Out) -> Option<T>;
fn contains(&self, key: &H::Out) -> bool;
fn insert(&mut self, value: &[u8]) -> H::Out;
fn emplace(&mut self, key: H::Out, value: T);
fn remove(&mut self, key: &H::Out);
}
#[cfg(feature = "std")]
pub trait AsHashDB<H: Hasher, T> {
fn as_hashdb(&self) -> &HashDB<H, T>;
fn as_hashdb_mut(&mut self) -> &mut HashDB<H, T>;
}
#[cfg(feature = "std")]
impl<'a, H: Hasher, T> AsHashDB<H, T> for &'a mut HashDB<H, T> {
fn as_hashdb(&self) -> &HashDB<H, T> { &**self }
fn as_hashdb_mut(&mut self) -> &mut HashDB<H, T> { &mut **self }
}