pub trait HashDB<H: Hasher, T>: Send + Sync + AsHashDB<H, T> {
// Required methods
fn get(&self, key: &H::Out, prefix: Prefix<'_>) -> Option<T>;
fn contains(&self, key: &H::Out, prefix: Prefix<'_>) -> bool;
fn insert(&mut self, prefix: Prefix<'_>, value: &[u8]) -> H::Out;
fn emplace(&mut self, key: H::Out, prefix: Prefix<'_>, value: T);
fn remove(&mut self, key: &H::Out, prefix: Prefix<'_>);
}
Expand description
Trait modelling datastore keyed by a hash defined by the Hasher
.
Required Methods§
sourcefn get(&self, key: &H::Out, prefix: Prefix<'_>) -> Option<T>
fn get(&self, key: &H::Out, prefix: Prefix<'_>) -> Option<T>
Look up a given hash into the bytes that hash to it, returning None if the hash is not known.
sourcefn contains(&self, key: &H::Out, prefix: Prefix<'_>) -> bool
fn contains(&self, key: &H::Out, prefix: Prefix<'_>) -> bool
Check for the existence of a hash-key.
sourcefn insert(&mut self, prefix: Prefix<'_>, value: &[u8]) -> H::Out
fn insert(&mut self, prefix: Prefix<'_>, value: &[u8]) -> H::Out
Insert a datum item into the DB and return the datum’s hash for a later lookup. Insertions
are counted and the equivalent number of remove()
s must be performed before the data
is considered dead.
Trait Implementations§
source§impl<'a, H: Hasher, T> AsHashDB<H, T> for &'a mut dyn HashDB<H, T>
impl<'a, H: Hasher, T> AsHashDB<H, T> for &'a mut dyn HashDB<H, T>
source§fn as_hash_db(&self) -> &dyn HashDB<H, T>
fn as_hash_db(&self) -> &dyn HashDB<H, T>
Perform upcast to HashDB for anything that derives from HashDB.
source§fn as_hash_db_mut<'b>(&'b mut self) -> &'b mut (dyn HashDB<H, T> + 'b)
fn as_hash_db_mut<'b>(&'b mut self) -> &'b mut (dyn HashDB<H, T> + 'b)
Perform mutable upcast to HashDB for anything that derives from HashDB.