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

Merklized key-value store where methods return errors instead of panicking.

Required Methods§

source

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

Fetch entry with given key.

source

fn get_proof(&self, key: &[u8]) -> Result<Option<Proof>>

Fetch proof for 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]) -> Result<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]) -> Result<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) -> Result<()>

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<Hash>

Commit all database changes to the underlying store.

Implementations on Foreign Types§

source§

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

source§

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

source§

fn get_proof(&self, key: &[u8]) -> Result<Option<Proof>>

source§

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

source§

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

source§

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

source§

fn prefetch_prefixes(&self, prefixes: &[Prefix], limit: u16) -> Result<()>

source§

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

source§

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

Implementors§