Crates.io | flumedb |
lib.rs | flumedb |
version | 0.1.6 |
source | src |
created_at | 2019-12-25 19:38:25.583698 |
updated_at | 2022-01-13 21:17:47.913909 |
description | Append-only log format used by Secure Scuttlebutt |
homepage | |
repository | https://github.com/sunrise-choir/flumedb-rs |
max_upload_size | |
id | 192371 |
size | 79,133 |
The Sunrise Choir Flume is a re-write of the JavaScript flumedb
into Rust with a new architecture for better performance and flexibility.
Flume is a modular database:
In flume, each view remembers a version number, and if the version number changes, it just rebuilds the view. This means view code can be easily updated, or new views added. It just rebuilds the view on startup.
use flumedb::Error;
use flumedb::OffsetLog;
fn main() -> Result<(), Error> {
let path = shellexpand::tilde("~/.ssb/flume/log.offset");
let log = OffsetLog::<u32>::open_read_only(path.as_ref())?;
// Read the entry at offset 0
let r = log.read(0)?;
// `r.data` is a json string in a standard ssb log.
// `r.next` is the offset of the next entry.
let r = log.read(r.next);
log.iter()
.map(|e| serde_json::from_slice::<serde_json::Value>(&e.data).unwrap())
.for_each(|v| println!("{}", serde_json::to_string_pretty(&v).unwrap()));
Ok(())
}