Skip to main content

BackingStore

Trait BackingStore 

Source
pub trait BackingStore<K, V> {
    // Required methods
    fn store(&mut self, key: &K, value: &V) -> Result<(), StoreError>;
    fn load(&self, key: &K) -> Option<V>;
    fn remove(&mut self, key: &K) -> bool;
}
Expand description

Abstraction over a synchronous persistent store.

Implementations are expected to be synchronous. For async I/O the caller can provide a blocking adapter.

Required Methods§

Source

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

Persist (key, value) to the backing store.

Source

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

Load the value associated with key, returning None if absent.

Source

fn remove(&mut self, key: &K) -> bool

Remove key from the backing store.

Returns true if the key existed and was removed.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl<K, V> BackingStore<K, V> for InMemoryStore<K, V>
where K: Eq + Hash + Clone, V: Clone,