pub trait Storage<K, V>: Send + Sync {
// Required methods
fn store(&mut self, key: K, value: V) -> StorageResult<()>;
fn clear(&mut self) -> StorageResult<()>;
fn get(&self, key: &K) -> StorageResult<Option<V>>;
fn take(&mut self, key: &K) -> StorageResult<Option<V>>;
fn keys(&self) -> StorageResult<Vec<K>>;
fn into_iter(&self) -> StorageResult<Box<dyn Iterator<Item = (K, V)> + '_>>;
fn count(&self) -> StorageResult<u64>;
fn clone_box(&self) -> Box<dyn Storage<K, V>>;
// Provided methods
fn contains_key(&self, key: &K) -> StorageResult<bool> { ... }
fn shutdown(&self) { ... }
fn as_overlay(&self) -> Option<&dyn OverlayLike<K, V>> { ... }
}Required Methods§
fn store(&mut self, key: K, value: V) -> StorageResult<()>
fn clear(&mut self) -> StorageResult<()>
fn get(&self, key: &K) -> StorageResult<Option<V>>
fn take(&mut self, key: &K) -> StorageResult<Option<V>>
fn keys(&self) -> StorageResult<Vec<K>>
fn into_iter(&self) -> StorageResult<Box<dyn Iterator<Item = (K, V)> + '_>>
Sourcefn count(&self) -> StorageResult<u64>
fn count(&self) -> StorageResult<u64>
Returns the number of entries in the storage.
fn clone_box(&self) -> Box<dyn Storage<K, V>>
Provided Methods§
fn contains_key(&self, key: &K) -> StorageResult<bool>
Sourcefn shutdown(&self)
fn shutdown(&self)
Explicitly shutdown the storage, performing any cleanup like WAL checkpoint. This should be called before the application exits to ensure data is persisted. Default implementation does nothing.
Sourcefn as_overlay(&self) -> Option<&dyn OverlayLike<K, V>>
fn as_overlay(&self) -> Option<&dyn OverlayLike<K, V>>
Returns Some if this storage is an overlay-style wrapper (OverlayStorage) whose
buffered writes/deletes can be drained for atomic commit semantics. Default None.
Used by the atomic Jito bundle commit path to flush a sandbox SVM’s overlay storages
back onto the original VM’s underlying storage on bundle success.
Trait Implementations§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".