Crates.io | mmap_buffer |
lib.rs | mmap_buffer |
version | 0.1.4 |
source | src |
created_at | 2023-04-01 22:24:20.018812 |
updated_at | 2023-04-21 01:46:08.94824 |
description | (Mostly) safe wrapper for a memory-backed buffer. |
homepage | |
repository | https://github.com/LevKruglyak/mmap-buffer |
max_upload_size | |
id | 827698 |
size | 12,875 |
(Mostly) safe wrapper for a fixed-size file-backed buffer.
use mmap_buffer::BackedBuffer;
fn main() -> Result<(), Box<dyn std::error::Error>> {
{
let mut buf = BackedBuffer::<i32>::new(100, "test.data")?;
// These changes will be reflected in the file
buf[10] = -10;
buf[20] = 27;
}
// Later, we can load the same array
let mut buf = BackedBuffer::<i32>::load("test.data")?;
assert_eq!(buf[10], -10);
assert_eq!(buf[20], 27);
Ok(())
}