KeyValueStore

Trait KeyValueStore 

Source
pub trait KeyValueStore {
    type Error;

    // Required methods
    async fn load(
        &self,
        key: &[u8],
        buf: &mut [u8],
    ) -> Result<Option<usize>, Self::Error>;
    async fn store(&self, key: &[u8], value: &[u8]) -> Result<(), Self::Error>;
    async fn delete(&self, key: &[u8]) -> Result<(), Self::Error>;
}
Expand description

Persistent key-value store used by higher layers for cached state.

Required Associated Types§

Required Methods§

Source

async fn load( &self, key: &[u8], buf: &mut [u8], ) -> Result<Option<usize>, Self::Error>

Load a value into buf, returning the stored length when present.

Source

async fn store(&self, key: &[u8], value: &[u8]) -> Result<(), Self::Error>

Store a value for key.

Source

async fn delete(&self, key: &[u8]) -> Result<(), Self::Error>

Delete any stored value for key.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§