From a6addc919f1a7fee4f53408b727a234bc896f28c Mon Sep 17 00:00:00 2001 From: Bjerg Date: Wed, 6 Sep 2023 05:39:15 +0200 Subject: [PATCH] chore: add small intro on rustdoc (#682) Co-authored-by: Christopher Berner --- src/lib.rs | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 79af589c..882be90f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,6 +9,48 @@ // TODO remove this once wasi no longer requires nightly #![cfg_attr(target_os = "wasi", feature(wasi_ext))] +//! # redb +//! +//! A simple, portable, high-performance, ACID, embedded key-value store. +//! +//! redb is written in pure Rust and is loosely inspired by [lmdb][lmdb]. Data is stored in a collection +//! of copy-on-write B-trees. For more details, see the [design doc][design]. +//! +//! # Features +//! +//! - Zero-copy, thread-safe, `BTreeMap` based API +//! - Fully ACID-compliant transactions +//! - MVCC support for concurrent readers & writer, without blocking +//! - Crash-safe by default +//! - Savepoints and rollbacks +//! +//! # Example +//! +//! ``` +//! use redb::{Database, Error, ReadableTable, TableDefinition}; +//! +//! const TABLE: TableDefinition<&str, u64> = TableDefinition::new("my_data"); +//! +//! fn main() -> Result<(), Error> { +//! let db = Database::create("my_db.redb")?; +//! let write_txn = db.begin_write()?; +//! { +//! let mut table = write_txn.open_table(TABLE)?; +//! table.insert("my_key", &123)?; +//! } +//! write_txn.commit()?; +//! +//! let read_txn = db.begin_read()?; +//! let table = read_txn.open_table(TABLE)?; +//! assert_eq!(table.get("my_key")?.unwrap().value(), 123); +//! +//! Ok(()) +//! } +//! ``` +//! +//! [lmdb]: https://www.lmdb.tech/doc/ +//! [design]: https://github.com/cberner/redb/blob/master/docs/design.md + pub use db::{ Builder, Database, MultimapTableDefinition, MultimapTableHandle, TableDefinition, TableHandle, UntypedMultimapTableHandle, UntypedTableHandle,