[−][src]Struct tari_storage::HashmapDatabase
The HMapDatabase mimics the behaviour of LMDBDatabase without keeping a persistent copy of the key-value records. It allows key-value pairs to be inserted, retrieved and removed in a thread-safe manner.
Implementations
impl<K: Clone + Eq + Hash, V: Clone> HashmapDatabase<K, V>
[src]
pub fn new() -> Self
[src]
Creates a new empty HMapDatabase with the specified name
pub fn insert(&self, key: K, value: V) -> Result<(), KeyValStoreError>
[src]
Inserts a key-value record into the database. Internally, insert
serializes the key and value using bincode
and adds the pair into HashMap guarded with a RwLock.
pub fn get(&self, key: &K) -> Result<Option<V>, KeyValStoreError>
[src]
Get a value from the key-value database. The retrieved value is deserialized from bincode into V
pub fn is_empty(&self) -> Result<bool, KeyValStoreError>
[src]
Returns if the key-value database is empty
pub fn len(&self) -> Result<usize, KeyValStoreError>
[src]
Returns the total number of entries recorded in the key-value database.
pub 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.
pub fn contains_key(&self, key: &K) -> Result<bool, KeyValStoreError>
[src]
Checks whether a record exist in the key-value database that corresponds to the provided key
.
pub fn remove(&self, key: &K) -> Result<(), KeyValStoreError>
[src]
Remove the record from the key-value database that corresponds with the provided key
.
Trait Implementations
impl<K: Default + Eq + Hash, V: Default> Default for HashmapDatabase<K, V>
[src]
fn default() -> HashmapDatabase<K, V>
[src]
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
.
fn for_each_ok<F>(&self, f: F) -> Result<(), KeyValStoreError> where
Self: Sized,
F: FnMut((K, V)) -> IterationResult,
[src]
Self: Sized,
F: FnMut((K, V)) -> IterationResult,
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,
fn filter_take<F>(
&self,
n: usize,
predicate: F
) -> Result<Vec<(K, V)>, KeyValStoreError> where
Self: Sized,
F: FnMut(&(K, V)) -> bool,
[src]
&self,
n: usize,
predicate: F
) -> Result<Vec<(K, V)>, KeyValStoreError> where
Self: Sized,
F: FnMut(&(K, V)) -> bool,
Auto Trait Implementations
impl<K, V> RefUnwindSafe for HashmapDatabase<K, V>
impl<K, V> Send for HashmapDatabase<K, V> where
K: Send,
V: Send,
K: Send,
V: Send,
impl<K, V> Sync for HashmapDatabase<K, V> where
K: Send + Sync,
V: Send + Sync,
K: Send + Sync,
V: Send + Sync,
impl<K, V> Unpin for HashmapDatabase<K, V> where
K: Unpin,
V: Unpin,
K: Unpin,
V: Unpin,
impl<K, V> UnwindSafe for HashmapDatabase<K, V>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Clear for T where
T: InitializableFromZeroed + ?Sized,
T: InitializableFromZeroed + ?Sized,
fn clear(&mut self)
impl<T> From<T> for T
[src]
impl<T> InitializableFromZeroed for T where
T: Default,
T: Default,
unsafe fn initialize(place: *mut T)
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> SafeBorrow<T> for T where
T: ?Sized,
T: ?Sized,
fn borrow_replacement(ptr: &T) -> &T
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,