stupid-simple-kv
A dead-simple, pluggable, and binary-sorted key-value store for Rust.
Features
- FoundationDB/Deno-style keys – type-safe, totally order-preserving keys using tuples, primitives, or your own struct, not macros.
- Zero-boilerplate get/set API – use tuple, struct, or primitive as key, no
.into_key()needed! - Easy decoding – get tuples/structs back using
FromKey. - Ergonomic builder API for filtered iteration:
Yieldskv . .prefix // use tuple or struct .start .end .iter(Key, T)pairs (key and value) as Rust types. - In-memory backend (
MemoryBackend) included. - Optional SQLite backend (
SqliteBackend) via feature flag (sqlite). - Easy pluggable backends: Implement the
KvBackendtrait for your store. - Store anything: Values are serialized to
Vec<u8>using bincode.
Installation
[]
= "0.1.0"
# To get the SQLite backend:
= { = "0.1.0", = ["sqlite"] }
Quickstart
use ;
let mut backend = new;
let mut kv = new;
// Store and fetch typed data
kv.set.unwrap;
let value: = kv.get.unwrap;
assert_eq!;
kv.delete.unwrap;
Iteration and Filtering
use ;
let mut kv = new;
for id in 1..=3
// Prefix filter:
let users: = kv.
.prefix // idiomatic filter
.iter
.collect;
// users: Vec<(Key, String)>
for in users
Decoding a key into types
use ;
let key = .into_key;
let : = from_key.unwrap;
// namespace == "foo", id == 42, flag == true
Custom struct keys
use ;
Using SQLite backend (optional)
Enable the feature:
[]
= { = "0.2.0", = ["sqlite"] }
Use in your code:
use ;
let mut backend = in_memory.unwrap;
let mut kv = new;
kv.set.unwrap;
Custom Backends
Just implement the KvBackend trait for your store. See
src/storages/kv_backend.rs.
License
MIT License © 2025 Siddharth S Singh (me@shantaram.xyz)