13 releases

0.3.0 Jul 12, 2026
0.2.11 Nov 20, 2026
0.2.10 Apr 11, 2026
0.2.9 Sep 12, 2025
0.1.2 Oct 28, 2024

#790 in Data structures

Download history 704/week @ 2026-07-31 559/week @ 2026-08-07 1630/week @ 2026-08-14 1678/week @ 2026-08-21 1040/week @ 2026-08-28 980/week @ 2026-09-04 2754/week @ 2026-09-11 986/week @ 2026-09-18 1014/week @ 2026-09-25 728/week @ 2026-10-02 2736/week @ 2026-10-09 332/week @ 2026-10-16 374/week @ 2026-10-23 597/week @ 2026-10-30 775/week @ 2026-11-06 1107/week @ 2026-11-13

2,908 downloads per month

MIT/Apache

155KB
3K SLoC

rotbl

read-only table


lib.rs:

Rotbl is a read-only on disk table of key-value.

use rotbl::v001::{Builder, Config, Rotbl, RotblMeta, SeqMarked};
#[tokio::main(flavor = "multi_thread")]
async fn main() {
use std::path::PathBuf;
use rotbl::storage::impls::fs::FsStorage;
let config = Config::default();
  #
  # // remove ./foo if exists
  # let _ = std::fs::remove_file("./foo");
  let r = {
    let storage = FsStorage::new(PathBuf::from("./"));
    let mut b = Builder::new(storage, config, "./foo").unwrap();

    // keys must be sorted
    b.append_kv("bar", SeqMarked::new_normal(1, b"bar".to_vec())).unwrap();
    b.append_kv("foo", SeqMarked::new_normal(2, b"foo".to_vec())).unwrap();

    Arc::new(b.commit(RotblMeta::new(1, "hello")).unwrap())
  };

  // Read the value back
  let val = r.get("foo").await.unwrap();
  assert_eq!(val, Some(SeqMarked::new_normal(2, b"foo".to_vec())));

  // Scan the table
  let kvs = r.range(..).try_collect::<Vec<_>>().await.unwrap();
  assert_eq!(kvs, vec![
                  ("bar".to_string(), SeqMarked::new_normal(1, b"bar".to_vec())),
                  ("foo".to_string(), SeqMarked::new_normal(2, b"foo".to_vec())),
  ]);
}

Dependencies

~11–16MB
~283K SLoC