#mmap #io #file #circular-buffer #ring-buffer


Cross-platform library for fast and safe memory-mapped IO

4 releases

0.1.3 Feb 9, 2019
0.1.2 Feb 9, 2019
0.1.1 Feb 9, 2019
0.1.0 Feb 9, 2019

#7 in #mmap

Download history

6 downloads per month

MIT license



A cross-platform library for fast and safe memory-mapped IO in Rust


A cross-platform library for fast and safe memory-mapped IO

This library defines a convenient API for reading and writing to files using the hosts virtual memory system. The design of the API strives to both minimize the frequency of mapping system calls while still retaining safe access.

Additionally, a variety of buffer implementations are provided in the vmap::io module.


# extern crate vmap;
# extern crate tempdir;
use vmap::Map;
use std::io::Write;
use std::fs::OpenOptions;
use std::path::PathBuf;
# use std::fs;

# fn main() -> std::io::Result<()> {
# let tmp = tempdir::TempDir::new("vmap")?;
let path: PathBuf = /* path to file */
# tmp.path().join("example");
# fs::write(&path, b"this is a test")?;
let file = OpenOptions::new().read(true).write(true).open(&path)?;

// Map the beginning of the file
let map = Map::file(&file, 0, 14)?;
assert_eq!(b"this is a test", &map[..]);

// Move the Map into a MapMut
// ... we could have started with MapMut::file(...)
let mut map = map.make_mut()?;
    let mut data = &mut map[..];

// Move the MapMut back into a Map
let map = map.make_read_only()?;
assert_eq!(b"that is a test", &map[..]);
# Ok(())
# }



  • unix libc 0.2
  • unix not linux android macos ios rand 0.5
  • windows winapi 0.3+winnt+sysinfoapi+handleapi+memoryapi