pub struct MemoryBackend { /* private fields */ }Expand description
In-memory storage backend for testing.
Implementations§
Source§impl MemoryBackend
impl MemoryBackend
Trait Implementations§
Source§impl Default for MemoryBackend
impl Default for MemoryBackend
Source§impl StorageBackend for MemoryBackend
impl StorageBackend for MemoryBackend
Source§fn get(&self, table: &str, key: &[u8]) -> Result<Option<Vec<u8>>>
fn get(&self, table: &str, key: &[u8]) -> Result<Option<Vec<u8>>>
Get a value by key from the specified table.
Source§fn put(&self, table: &str, key: &[u8], value: &[u8]) -> Result<()>
fn put(&self, table: &str, key: &[u8], value: &[u8]) -> Result<()>
Store a key-value pair in the specified table.
Source§fn delete(&self, table: &str, key: &[u8]) -> Result<bool>
fn delete(&self, table: &str, key: &[u8]) -> Result<bool>
Delete a key from the specified table. Returns true if the key existed.
Source§fn list(&self, table: &str) -> Result<Vec<(Vec<u8>, Vec<u8>)>>
fn list(&self, table: &str) -> Result<Vec<(Vec<u8>, Vec<u8>)>>
List all key-value pairs in the specified table.
Source§fn list_keys_with_prefix(
&self,
table: &str,
prefix: &[u8],
) -> Result<Vec<Vec<u8>>>
fn list_keys_with_prefix( &self, table: &str, prefix: &[u8], ) -> Result<Vec<Vec<u8>>>
List only the keys (no values) in the specified table whose bytes
start with
prefix. The default implementation falls back to a full
scan and is suitable for backends without a native prefix iterator.Source§fn delete_batch(&self, table: &str, keys: &[&[u8]]) -> Result<()>
fn delete_batch(&self, table: &str, keys: &[&[u8]]) -> Result<()>
Delete multiple keys from the specified table in a single atomic
operation. The default implementation calls
delete per key and is
not atomic; backends with transaction support should override this.Source§fn put_batch(&self, table: &str, entries: &[(&[u8], &[u8])]) -> Result<()>
fn put_batch(&self, table: &str, entries: &[(&[u8], &[u8])]) -> Result<()>
Store multiple key-value pairs in a single atomic operation.
Source§fn write_atomic(&self, ops: &[AtomicOp<'_>]) -> Result<()>
fn write_atomic(&self, ops: &[AtomicOp<'_>]) -> Result<()>
Apply several put/delete operations across tables. The default implementation applies each op
sequentially via
put/delete and is NOT atomic; backends with transaction support should
override this so a crash mid-batch cannot leave the ops half-applied. Each op must target a
DISTINCT table.Source§fn run_migrations(&self) -> Result<MigrationResult>
fn run_migrations(&self) -> Result<MigrationResult>
Run pending migrations. Read more
Auto Trait Implementations§
impl !Freeze for MemoryBackend
impl Forget for MemoryBackend
impl Move for MemoryBackend
impl RefUnwindSafe for MemoryBackend
impl Send for MemoryBackend
impl Sync for MemoryBackend
impl Unpin for MemoryBackend
impl UnsafeUnpin for MemoryBackend
impl UnwindSafe for MemoryBackend
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