Skip to main content

Storage

Trait Storage 

Source
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§

Source

fn store(&mut self, key: K, value: V) -> StorageResult<()>

Source

fn clear(&mut self) -> StorageResult<()>

Source

fn get(&self, key: &K) -> StorageResult<Option<V>>

Source

fn take(&mut self, key: &K) -> StorageResult<Option<V>>

Source

fn keys(&self) -> StorageResult<Vec<K>>

Source

fn into_iter(&self) -> StorageResult<Box<dyn Iterator<Item = (K, V)> + '_>>

Source

fn count(&self) -> StorageResult<u64>

Returns the number of entries in the storage.

Source

fn clone_box(&self) -> Box<dyn Storage<K, V>>

Provided Methods§

Source

fn contains_key(&self, key: &K) -> StorageResult<bool>

Source

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.

Source

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§

Source§

impl<K, V> Clone for Box<dyn Storage<K, V>>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<K, V> Storage<K, V> for FifoMap<K, V>
where K: Serialize + for<'de> Deserialize<'de> + Clone + Send + Sync + 'static + Eq + Hash, V: Serialize + for<'de> Deserialize<'de> + Clone + Send + Sync + 'static,

Source§

impl<K, V> Storage<K, V> for HashMap<K, V>
where K: Serialize + for<'de> Deserialize<'de> + Clone + Send + Sync + 'static + Eq + Hash, V: Serialize + for<'de> Deserialize<'de> + Clone + Send + Sync + 'static,

Source§

impl<K, V> Storage<K, V> for OverlayStorage<K, V>
where K: Serialize + for<'de> Deserialize<'de> + Clone + Eq + Hash + Send + Sync + 'static, V: Serialize + for<'de> Deserialize<'de> + Clone + Send + Sync + 'static,

Source§

impl<K, V> Storage<K, V> for SqliteStorage<K, V>
where K: Serialize + for<'de> Deserialize<'de> + Clone + Send + Sync + 'static, V: Serialize + for<'de> Deserialize<'de> + Clone + Send + Sync + 'static,