extern crate elastic_array;
extern crate ethereum_types;
use std::collections::HashMap;
use elastic_array::ElasticArray128;
use ethereum_types::H256;
pub type DBValue = ElasticArray128<u8>;
pub trait HashDB: AsHashDB + Send + Sync {
fn keys(&self) -> HashMap<H256, i32>;
fn get(&self, key: &H256) -> Option<DBValue>;
fn contains(&self, key: &H256) -> bool;
fn insert(&mut self, value: &[u8]) -> H256;
fn emplace(&mut self, key: H256, value: DBValue);
fn remove(&mut self, key: &H256);
}
pub trait AsHashDB {
fn as_hashdb(&self) -> &HashDB;
fn as_hashdb_mut(&mut self) -> &mut HashDB;
}
impl<T: HashDB> AsHashDB for T {
fn as_hashdb(&self) -> &HashDB {
self
}
fn as_hashdb_mut(&mut self) -> &mut HashDB {
self
}
}
impl<'a> AsHashDB for &'a mut HashDB {
fn as_hashdb(&self) -> &HashDB {
&**self
}
fn as_hashdb_mut(&mut self) -> &mut HashDB {
&mut **self
}
}