pub trait KeyValueStore {
    type Error: Debug;
    type WriteBatch<'a>: WriteBatch;

    // Required methods
    fn put(&self, key: &[u8], value: &[u8]) -> Result<(), Self::Error>;
    fn del(&self, key: &[u8]) -> Result<(), Self::Error>;
    fn write(
        &self,
        write_batch: Self::WriteBatch<'_>
    ) -> Result<(), Self::Error>;
}
Expand description

A write-oriented key-value store. KeyValueStore is a pun on register store.

Required Associated Types§

source

type Error: Debug

The type of error returned by this KeyValueStore.

source

type WriteBatch<'a>: WriteBatch

The type of write batch accepted by this KeyValueStore.

Required Methods§

source

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

Put the specified key as a single, isolated write.

source

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

Delete the specified key as a single, isolated write by writing a tombstone.

source

fn write(&self, write_batch: Self::WriteBatch<'_>) -> Result<(), Self::Error>

Write the batch to the key-value store. Whether this is atomic depends upon the key-value store itself.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<K: KeyValueStore> KeyValueStore for Arc<K>

§

type Error = <K as KeyValueStore>::Error

§

type WriteBatch<'a> = <K as KeyValueStore>::WriteBatch<'a>

source§

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

source§

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

source§

fn write(&self, write_batch: Self::WriteBatch<'_>) -> Result<(), Self::Error>

Implementors§