stack_db/
lib.rs

1//! # stack-db
2//! > A (basically) infinitely stacking database that has both readonly safety and incredible write speeds at the same time.
3//! 
4//! ## Examples
5//! ---
6//! ### Example of a basic in-memory binary database
7//! Here is a basic in-memory database that only deals with binary indexes and data (that uses the allocators provided by the library)
8//! ```rust
9//! use stack_db::prelude::*;
10//! 
11//! let allocator = SkdbMemAlloc; // or `SkdbDiskAlloc::new()`
12//! let mut database = StackDB::new(allocator).unwrap();
13//! 
14//! // writing
15//! database.write(256, b"hello, ").unwrap();
16//! database.write(256+7, b"world").unwrap();
17//! 
18//! // reading
19//! assert_eq!(&*database.read(256..268).unwrap(), b"hello, world");
20//! 
21//! // commit to save all changes
22//! database.commit().unwrap();
23//! 
24//! // over-writting
25//! database.write(256, b"H").unwrap();
26//! database.write(256+7, b"W").unwrap();
27//! database.write(268, b"!").unwrap();
28//! 
29//! // commit again
30//! database.commit().unwrap();
31//! 
32//! // reading
33//! assert_eq!(&*database.read(256..269).unwrap(), b"Hello, World!");
34//! 
35//! // rebase to save space
36//! database.rebase(256).unwrap(); // rebase with a 256 byte buffer
37//! ```
38
39pub mod base;
40pub mod errors;
41pub mod prelude;
42pub mod default;
43
44#[cfg(debug_assertions)]
45#[allow(dead_code)]
46fn check_iter_val<T: std::fmt::Debug>(value: T) -> T {
47    dbg!(&value);
48    value
49}