pub struct InMemory { /* private fields */ }Expand description
A key-value database fulfilling the KeyValueDB trait, living in memory.
This is generally intended for tests and is not particularly optimized.
Trait Implementations§
Source§impl KeyValueDB for InMemory
impl KeyValueDB for InMemory
Source§fn delete<'a>(
&'a self,
col: u32,
key: &'a [u8],
) -> KeyValueDBPinBoxFuture<'a, Result<Option<DBValue>>>
fn delete<'a>( &'a self, col: u32, key: &'a [u8], ) -> KeyValueDBPinBoxFuture<'a, Result<Option<DBValue>>>
Remove a value by key, returning the old value
Source§fn get<'a>(
&'a self,
col: u32,
key: &'a [u8],
) -> KeyValueDBPinBoxFuture<'a, Result<Option<DBValue>>>
fn get<'a>( &'a self, col: u32, key: &'a [u8], ) -> KeyValueDBPinBoxFuture<'a, Result<Option<DBValue>>>
Get a value by key.
Source§fn write(
&self,
transaction: DBTransaction,
) -> KeyValueDBPinBoxFuture<'_, Result<(), DBTransactionError>>
fn write( &self, transaction: DBTransaction, ) -> KeyValueDBPinBoxFuture<'_, Result<(), DBTransactionError>>
Write a transaction of changes to the backing store.
Source§fn iter<'a, T: Send + 'static, C: Send + 'static, F: FnMut(&mut C, DBKeyValueRef<'_>) -> Result<Option<T>> + Send + Sync + 'static>(
&'a self,
col: u32,
prefix: Option<&'a [u8]>,
context: C,
f: F,
) -> KeyValueDBPinBoxFuture<'a, Result<(C, Option<T>)>>
fn iter<'a, T: Send + 'static, C: Send + 'static, F: FnMut(&mut C, DBKeyValueRef<'_>) -> Result<Option<T>> + Send + Sync + 'static>( &'a self, col: u32, prefix: Option<&'a [u8]>, context: C, f: F, ) -> KeyValueDBPinBoxFuture<'a, Result<(C, Option<T>)>>
Iterate over the data for a given column.
Return all key/value pairs, optionally where the key starts with the given prefix.
Iterator closure returns true for more items, false to stop iteration.
Source§fn iter_keys<'a, T: Send + 'static, C: Send + 'static, F: FnMut(&mut C, DBKeyRef<'_>) -> Result<Option<T>> + Send + Sync + 'static>(
&'a self,
col: u32,
prefix: Option<&'a [u8]>,
context: C,
f: F,
) -> KeyValueDBPinBoxFuture<'a, Result<(C, Option<T>)>>
fn iter_keys<'a, T: Send + 'static, C: Send + 'static, F: FnMut(&mut C, DBKeyRef<'_>) -> Result<Option<T>> + Send + Sync + 'static>( &'a self, col: u32, prefix: Option<&'a [u8]>, context: C, f: F, ) -> KeyValueDBPinBoxFuture<'a, Result<(C, Option<T>)>>
Iterate over the data for a given column.
Return all keys, optionally where the key starts with the given prefix.
Iterator closure returns true for more items, false to stop iteration.
Source§fn num_columns(&self) -> Result<u32>
fn num_columns(&self) -> Result<u32>
The number of column families in the db.
Source§fn num_keys(&self, col: u32) -> KeyValueDBPinBoxFuture<'_, Result<u64>>
fn num_keys(&self, col: u32) -> KeyValueDBPinBoxFuture<'_, Result<u64>>
The number of keys in a column (estimated).
Source§fn transaction(&self) -> DBTransaction
fn transaction(&self) -> DBTransaction
Helper to create a new transaction.
Source§fn has_key<'a>(
&'a self,
col: u32,
key: &'a [u8],
) -> Pin<Box<dyn Future<Output = Result<bool, Error>> + Send + 'a>>
fn has_key<'a>( &'a self, col: u32, key: &'a [u8], ) -> Pin<Box<dyn Future<Output = Result<bool, Error>> + Send + 'a>>
Check for the existence of a value by key.
Source§fn has_prefix<'a>(
&'a self,
col: u32,
prefix: &'a [u8],
) -> Pin<Box<dyn Future<Output = Result<bool, Error>> + Send + 'a>>
fn has_prefix<'a>( &'a self, col: u32, prefix: &'a [u8], ) -> Pin<Box<dyn Future<Output = Result<bool, Error>> + Send + 'a>>
Check for the existence of a value by prefix.
Auto Trait Implementations§
impl Freeze for InMemory
impl !RefUnwindSafe for InMemory
impl Send for InMemory
impl Sync for InMemory
impl Unpin for InMemory
impl !UnwindSafe for InMemory
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more