Trait oasis_core_runtime::storage::mkvs::FallibleMKVS
source · 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§
sourcefn cache_contains_key(&self, key: &[u8]) -> bool
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.
sourcefn insert(&mut self, key: &[u8], value: &[u8]) -> Result<Option<Vec<u8>>>
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.
sourcefn remove(&mut self, key: &[u8]) -> Result<Option<Vec<u8>>>
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.