stack-db 0.3.5

A (basically) infinitely stacking & extendable CoW database that has both readonly safety and incredible write speeds at the same time.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use std::{borrow::Cow, io::Cursor};
use stack_db::base::layer::Layer;

#[test]
fn test_read_write() {
    let mut layer_data = vec![0u8; 256];
    let mut layer = Layer::new(Cursor::new(&mut layer_data));

    layer.write_unchecked(128, Cow::Borrowed(b"hello, world")).unwrap();
    layer.write_unchecked(4, Cow::Borrowed(&[0, 1, 2, 3, 4, 5, 6, 7, 8])).unwrap();

    assert_eq!(&*layer.read_unchecked(&(128..140)).unwrap().1, b"hello, world");
    layer.flush().unwrap();

    assert_eq!(&*layer.read_unchecked(&(4..13)).unwrap().1, &[0, 1, 2, 3, 4, 5, 6, 7, 8]);
}