stupid-simple-kv 0.1.0

A dead-simple, pluggable, binary-sorted key-value store for Rust with FoundationDB-style keys. In-memory and SQLite backends. Zero-boilerplate and easy iteration.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/// Traits and core types for key-value backends.
use crate::keys::Key;
pub type KvError = Box<dyn std::error::Error + Send + Sync>;
pub type KvResult<T> = Result<T, KvError>;

/// A pluggable key-value backend trait. See implementations for in-memory and SQLite backends.
pub trait KvBackend {
    fn set(&mut self, key: Key, value: Vec<u8>) -> KvResult<()>;
    fn get(&self, key: &Key) -> KvResult<Option<Vec<u8>>>;
    fn delete(&mut self, key: &Key) -> KvResult<()>;
    fn clear(&mut self) -> KvResult<()>;
    fn get_many(&self, keys: Vec<Key>) -> KvResult<Box<dyn Iterator<Item = Vec<u8>> + Send + Sync + 'static>>;
    fn keys(&self) -> KvResult<Box<dyn Iterator<Item = Key> + Send + Sync + 'static>>;
}