pub struct MemoryStorage { /* private fields */ }Expand description
In-memory storage backend for testing and development.
Uses a BTreeMap to store slot values in memory. This enables fast,
isolated unit tests without requiring a WASM runtime or blockchain.
§Example
ⓘ
use truthlinked_sdk::backend::MemoryStorage;
let mut storage = MemoryStorage::new()
.with_slot([1u8; 32], [42u8; 32])
.with_slot([2u8; 32], [99u8; 32]);
let snapshot = storage.snapshot(); // Clone current stateImplementations§
Source§impl MemoryStorage
impl MemoryStorage
Sourcepub fn snapshot(&self) -> BTreeMap<[u8; 32], [u8; 32]>
pub fn snapshot(&self) -> BTreeMap<[u8; 32], [u8; 32]>
Creates a snapshot of the current storage state.
Returns a clone of the internal slot map. Useful for:
- Saving state before mutations
- Comparing state changes in tests
- Debugging storage operations
§Returns
A BTreeMap containing all current slot values.
Trait Implementations§
Source§impl Clone for MemoryStorage
impl Clone for MemoryStorage
Source§fn clone(&self) -> MemoryStorage
fn clone(&self) -> MemoryStorage
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MemoryStorage
impl Debug for MemoryStorage
Source§impl Default for MemoryStorage
impl Default for MemoryStorage
Source§fn default() -> MemoryStorage
fn default() -> MemoryStorage
Returns the “default value” for a type. Read more
Source§impl StorageBackend for MemoryStorage
impl StorageBackend for MemoryStorage
Auto Trait Implementations§
impl Freeze for MemoryStorage
impl RefUnwindSafe for MemoryStorage
impl Send for MemoryStorage
impl Sync for MemoryStorage
impl Unpin for MemoryStorage
impl UnsafeUnpin for MemoryStorage
impl UnwindSafe for MemoryStorage
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