HashDB

Trait HashDB 

Source
pub trait HashDB<H: Hasher, T>:
    Send
    + Sync
    + AsHashDB<H, T> {
    // Required methods
    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);
}
Expand description

Trait modelling datastore keyed by a hash defined by the Hasher.

Required Methods§

Source

fn keys(&self) -> HashMap<H::Out, i32>

Get the keys in the database together with number of underlying references.

Source

fn get(&self, key: &H::Out) -> Option<T>

Look up a given hash into the bytes that hash to it, returning None if the hash is not known.

Source

fn contains(&self, key: &H::Out) -> bool

Check for the existance of a hash-key.

Source

fn insert(&mut self, 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.

Source

fn emplace(&mut self, key: H::Out, value: T)

Like insert(), except you provide the key and the data is all moved.

Source

fn remove(&mut self, key: &H::Out)

Remove a datum previously inserted. Insertions can be “owed” such that the same number of insert()s may happen without the data being eventually being inserted into the DB. It can be “owed” more than once.

Trait Implementations§

Source§

impl<'a, H: Hasher, T> AsHashDB<H, T> for &'a mut dyn HashDB<H, T>

Available on crate feature std only.
Source§

fn as_hashdb(&self) -> &dyn HashDB<H, T>

Perform upcast to HashDB for anything that derives from HashDB.
Source§

fn as_hashdb_mut(&mut self) -> &mut dyn HashDB<H, T>

Perform mutable upcast to HashDB for anything that derives from HashDB.

Implementors§