#db #schema #deserialize #rustaceans #store


fast, embedded, transactional, key value store

17 releases

new 0.1.17 Mar 19, 2023
0.1.16 Feb 18, 2023
0.1.0 Jan 13, 2023

#847 in Database interfaces

Download history 21/week @ 2023-01-08 2/week @ 2023-01-15 3/week @ 2023-01-22 93/week @ 2023-01-29 196/week @ 2023-02-05 160/week @ 2023-02-12 87/week @ 2023-02-19 9/week @ 2023-02-26 12/week @ 2023-03-05 8/week @ 2023-03-12

150 downloads per month
Used in db-rs-derive


798 lines


An ergonomic, embedded, single-threaded database for Rustaceans.


  • Define a schema in Rust.
  • Use your types in the database as long as they implement Serialize and Deserialize. You don't have to fuss around with converting your data to database-specific types.
  • All your database interactions are typesafe. When you type db., your tooling will suggest a list of your tables. When you select a table, you'll be greeted with that table-type's contract populated with your types. No need to wrap your db in a handwritten type safe contract.
  • Supports a variety of simple data-structures, including LookupTables, Lists, and many more. Implementing your own table types is trivial.
  • All table mutations are persisted to an append only log using the fast & compact bincode representation of your types.
  • You can begin_transaction()s to express atomic updates to multiple tables.


Add the following to your Cargo.toml:

db-rs = "0.1.17"
db-rs-derive = "0.1.17"

Define your schema:

use db_rs_derive::Schema;
use db_rs::{Single, LookupTable};

struct SchemaV1 {
    owner: Single<Username>,
    admins: List<Username>,
    users: LookupTable<Username, Account>,

Initialize your DB:

use db_rs::Db;
use db_rs::Config;

fn main() {
    let mut db = SchemaV1::init(Config::in_folder("/tmp/test/"))?;

Active areas of thought and research

  • Because the db implementation (like redis) is single threaded, it forces you to achieve application throughput via low latency rather than concurrency. Currently, this suits our needs. Simply being embedded gives us more than enough throughput compared to something like Postgres. For use in a server-style setting put the database in an Arc<Mutex<>>.
  • The database offers no tools at the moment to define integrity constraints beyond what the Rust type system implicitly enforces (non-null for instance). At the moment for us, this is simply an application side concern.

Used by


~38K SLoC