[−][src]Trait tari_storage::KeyValueStore
General CRUD behaviour of Key-value store implementations.
Required methods
fn insert(&self, key: K, value: V) -> Result<(), KeyValStoreError>
[src]
Inserts a key-value pair into the key-value database.
fn get(&self, key: &K) -> Result<Option<V>, KeyValStoreError>
[src]
Get the value corresponding to the provided key from the key-value database.
fn size(&self) -> Result<usize, KeyValStoreError>
[src]
Returns the total number of entries recorded in the key-value database.
fn for_each<F>(&self, f: F) -> Result<(), KeyValStoreError> where
Self: Sized,
F: FnMut(Result<(K, V), KeyValStoreError>) -> IterationResult,
[src]
Self: Sized,
F: FnMut(Result<(K, V), KeyValStoreError>) -> IterationResult,
Execute function f
for each value in the database.
f
is a closure of form |pair: Result<(K,V), KeyValStoreError>| -> IterationResult
.
If IterationResult::Break
is returned the closure will not be called again and
for_each
will return. You will usually need to include type inference to let
Rust know which type to deserialise to:
let res = db.for_each::<Key, Val, _>(|pair| {
let (key, val) = pair.unwrap();
//.. do stuff with key and val..
});
fn exists(&self, key: &K) -> Result<bool, KeyValStoreError>
[src]
Checks whether the provided key
exists in the key-value database.
fn delete(&self, key: &K) -> Result<(), KeyValStoreError>
[src]
Delete a key-pair record associated with the provided key
from the key-pair database.
Provided methods
fn for_each_ok<F>(&self, mut f: F) -> Result<(), KeyValStoreError> where
Self: Sized,
F: FnMut((K, V)) -> IterationResult,
[src]
Self: Sized,
F: FnMut((K, V)) -> IterationResult,
Execute function f
for each value in the database. Any errors are filtered out.
This is useful for any caller which could not do any better with an error
than filtering it out.
f
is a closure of form |pair: (K,V)| -> ()
. You will usually need to include type
inference to let Rust know which type to deserialise to:
let res = db.for_each_ok::<Key, Val, _>(|(key, val)| {
//.. do stuff with key and val..
});
fn filter<F>(&self, predicate: F) -> Result<Vec<(K, V)>, KeyValStoreError> where
Self: Sized,
F: FnMut(&(K, V)) -> bool,
[src]
Self: Sized,
F: FnMut(&(K, V)) -> bool,
Return a Vec<(K, V)>
filtered by the predicate.
Bare in mind that this is not an Iterator
and filter will fetch data eagerly.
fn filter_take<F>(
&self,
n: usize,
mut predicate: F
) -> Result<Vec<(K, V)>, KeyValStoreError> where
Self: Sized,
F: FnMut(&(K, V)) -> bool,
[src]
&self,
n: usize,
mut predicate: F
) -> Result<Vec<(K, V)>, KeyValStoreError> where
Self: Sized,
F: FnMut(&(K, V)) -> bool,
Return a Vec<(K, V)>
filtered by the predicate. At most n
pairs are returned.
Implementors
impl<K, V> KeyValueStore<K, V> for LMDBWrapper<K, V> where
K: AsLmdbBytes + DeserializeOwned,
V: Serialize + DeserializeOwned,
[src]
K: AsLmdbBytes + DeserializeOwned,
V: Serialize + DeserializeOwned,
fn insert(&self, key: K, value: V) -> Result<(), KeyValStoreError>
[src]
Inserts a key-value pair into the key-value database.
fn get(&self, key: &K) -> Result<Option<V>, KeyValStoreError> where
V: DeserializeOwned,
[src]
V: DeserializeOwned,
Get the value corresponding to the provided key from the key-value database.
fn size(&self) -> Result<usize, KeyValStoreError>
[src]
Returns the total number of entries recorded in the key-value database.
fn for_each<F>(&self, f: F) -> Result<(), KeyValStoreError> where
F: FnMut(Result<(K, V), KeyValStoreError>) -> IterationResult,
[src]
F: FnMut(Result<(K, V), KeyValStoreError>) -> IterationResult,
Iterate over all the stored records and execute the function f
for each pair in the key-value database.
fn exists(&self, key: &K) -> Result<bool, KeyValStoreError>
[src]
Checks whether a record exist in the key-value database that corresponds to the provided key
.
fn delete(&self, key: &K) -> Result<(), KeyValStoreError>
[src]
Remove the record from the key-value database that corresponds with the provided key
.
impl<K: Clone + Eq + Hash, V: Clone> KeyValueStore<K, V> for HashmapDatabase<K, V>
[src]
fn insert(&self, key: K, value: V) -> Result<(), KeyValStoreError>
[src]
Inserts a key-value pair into the key-value database.
fn get(&self, key: &K) -> Result<Option<V>, KeyValStoreError>
[src]
Get the value corresponding to the provided key from the key-value database.
fn size(&self) -> Result<usize, KeyValStoreError>
[src]
Returns the total number of entries recorded in the key-value database.
fn for_each<F>(&self, f: F) -> Result<(), KeyValStoreError> where
F: FnMut(Result<(K, V), KeyValStoreError>) -> IterationResult,
[src]
F: FnMut(Result<(K, V), KeyValStoreError>) -> IterationResult,
Iterate over all the stored records and execute the function f
for each pair in the key-value database.
fn exists(&self, key: &K) -> Result<bool, KeyValStoreError>
[src]
Checks whether a record exist in the key-value database that corresponds to the provided key
.
fn delete(&self, key: &K) -> Result<(), KeyValStoreError>
[src]
Remove the record from the key-value database that corresponds with the provided key
.