pub trait MKVS {
    // Required methods
    fn get(&self, key: &[u8]) -> Option<Vec<u8>>;
    fn cache_contains_key(&self, key: &[u8]) -> bool;
    fn insert(&mut self, key: &[u8], value: &[u8]) -> Option<Vec<u8>>;
    fn remove(&mut self, key: &[u8]) -> Option<Vec<u8>>;
    fn prefetch_prefixes(&self, prefixes: &[Prefix], limit: u16);
    fn iter(&self) -> Box<dyn Iterator + '_>;
    fn commit(
        &mut self,
        namespace: Namespace,
        version: u64
    ) -> Result<(WriteLog, Hash)>;
}
Expand description

Merklized key-value store.

Required Methods§

source

fn get(&self, key: &[u8]) -> Option<Vec<u8>>

Fetch entry with given key.

source

fn cache_contains_key(&self, key: &[u8]) -> bool

Check if the local MKVS cache contains the given key.

While get can be used to check if the MKVS as a whole contains a given key, this function specifically guarantees that no remote syncing will be invoked, only checking the local cache.

source

fn insert(&mut self, key: &[u8], value: &[u8]) -> Option<Vec<u8>>

Update entry with given key.

If the database did not have this key present, None is returned.

If the database did have this key present, the value is updated, and the old value is returned.

source

fn remove(&mut self, key: &[u8]) -> Option<Vec<u8>>

Remove entry with given key, returning the value at the key if the key was previously in the database.

source

fn prefetch_prefixes(&self, prefixes: &[Prefix], limit: u16)

Populate the in-memory tree with nodes for keys starting with given prefixes.

source

fn iter(&self) -> Box<dyn Iterator + '_>

Returns an iterator over the tree.

source

fn commit( &mut self, namespace: Namespace, version: u64 ) -> Result<(WriteLog, Hash)>

Commit all database changes to the underlying store.

Implementations on Foreign Types§

source§

impl<T: MKVS + ?Sized> MKVS for &mut T

source§

fn get(&self, key: &[u8]) -> Option<Vec<u8>>

source§

fn cache_contains_key(&self, key: &[u8]) -> bool

source§

fn insert(&mut self, key: &[u8], value: &[u8]) -> Option<Vec<u8>>

source§

fn remove(&mut self, key: &[u8]) -> Option<Vec<u8>>

source§

fn prefetch_prefixes(&self, prefixes: &[Prefix], limit: u16)

source§

fn iter(&self) -> Box<dyn Iterator + '_>

source§

fn commit( &mut self, namespace: Namespace, version: u64 ) -> Result<(WriteLog, Hash)>

Implementors§