Expand description
Storage backend abstraction for contract state persistence.
This module provides a trait-based abstraction over storage operations, enabling both production (on-chain) and testing (in-memory) backends.
§Storage Backends
HostStorage: Production backend that delegates to WASM host imports. Used when contracts run on-chain.MemoryStorage: In-memory backend usingBTreeMapfor testing. Enables fast, isolated unit tests without WASM runtime.
§Example
ⓘ
use truthlinked_sdk::backend::{StorageBackend, MemoryStorage};
// Testing with in-memory storage
let mut storage = MemoryStorage::new();
let slot = [1u8; 32];
storage.write_32(slot, [42u8; 32])?;
let value = storage.read_32(&slot)?;
assert_eq!(value[0], 42);Structs§
- Host
Storage - Storage backend that delegates to WASM host imports.
- Memory
Storage - In-memory storage backend for testing and development.
Traits§
- Storage
Backend - Trait for storage backends that support 32-byte slot read/write operations.