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>(
&self,
col: u32,
key: &'a [u8],
) -> Pin<Box<dyn Future<Output = Result<Option<DBValue>>> + Send + 'a>>
fn delete<'a>( &self, col: u32, key: &'a [u8], ) -> Pin<Box<dyn Future<Output = Result<Option<DBValue>>> + Send + 'a>>
Remove a value by key, returning the old value
Source§fn get<'a>(
&self,
col: u32,
key: &'a [u8],
) -> Pin<Box<dyn Future<Output = Result<Option<DBValue>>> + Send + 'a>>
fn get<'a>( &self, col: u32, key: &'a [u8], ) -> Pin<Box<dyn Future<Output = Result<Option<DBValue>>> + Send + 'a>>
Get a value by key.
Source§fn write(
&self,
transaction: DBTransaction,
) -> Pin<Box<dyn Future<Output = Result<(), DBTransactionError>> + Send>>
fn write( &self, transaction: DBTransaction, ) -> Pin<Box<dyn Future<Output = Result<(), DBTransactionError>> + Send>>
Write a transaction of changes to the backing store.
Source§fn iter<'a, T: 'a, F: FnMut(DBKeyValueRef<'_>) -> Result<Option<T>> + Send + Sync + 'a>(
&self,
col: u32,
prefix: Option<&'a [u8]>,
f: F,
) -> Pin<Box<dyn Future<Output = Result<Option<T>>> + Send + 'a>>
fn iter<'a, T: 'a, F: FnMut(DBKeyValueRef<'_>) -> Result<Option<T>> + Send + Sync + 'a>( &self, col: u32, prefix: Option<&'a [u8]>, f: F, ) -> Pin<Box<dyn Future<Output = Result<Option<T>>> + Send + 'a>>
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: 'a, F: FnMut(DBKeyRef<'_>) -> Result<Option<T>> + Send + Sync + 'a>(
&self,
col: u32,
prefix: Option<&'a [u8]>,
f: F,
) -> Pin<Box<dyn Future<Output = Result<Option<T>>> + Send + 'a>>
fn iter_keys<'a, T: 'a, F: FnMut(DBKeyRef<'_>) -> Result<Option<T>> + Send + Sync + 'a>( &self, col: u32, prefix: Option<&'a [u8]>, f: F, ) -> Pin<Box<dyn Future<Output = Result<Option<T>>> + Send + 'a>>
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,
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send>>
fn num_keys( &self, col: u32, ) -> Pin<Box<dyn Future<Output = Result<u64>> + Send>>
The number of keys in a column (estimated).
Source§fn restore(&self, _new_db: &str) -> Result<()>
fn restore(&self, _new_db: &str) -> Result<()>
Attempt to replace this database with a new one located at the given path.
Source§fn transaction(&self) -> DBTransaction
fn transaction(&self) -> DBTransaction
Helper to create a new transaction.
Source§fn has_key<'a>(
&self,
col: u32,
key: &'a [u8],
) -> Pin<Box<dyn Future<Output = Result<bool, Error>> + Send + 'a>>
fn has_key<'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.
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