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) { ... }
}

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.

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

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

Performs copy-assignment from source. Read more

Implementors§

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,

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,