mmap_buffer

Crates.iommap_buffer
lib.rsmmap_buffer
version0.1.4
sourcesrc
created_at2023-04-01 22:24:20.018812
updated_at2023-04-21 01:46:08.94824
description(Mostly) safe wrapper for a memory-backed buffer.
homepage
repositoryhttps://github.com/LevKruglyak/mmap-buffer
max_upload_size
id827698
size12,875
Lev Kruglyak (LevKruglyak)

documentation

README

mmap-buffer

(Mostly) safe wrapper for a fixed-size file-backed buffer.

Example

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(())
}
Commit count: 10

cargo fmt