[−][src]Crate vmap
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.
Example
use vmap::Map; use std::io::Write; use std::fs::OpenOptions; use std::path::PathBuf; let path: PathBuf = /* path to file */ 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[..]; data.write_all(b"that")?; } // Move the MapMut back into a Map let map = map.make_read_only()?; assert_eq!(b"that is a test", &map[..]);
Modules
io | Read/Write types for buffering. |
os | Low-level cross-platform virtual memory functions |
Structs
AllocSize | Type for calculation page size information. |
Map | Allocation of one or more read-only sequential pages. |
MapMut | Allocation of one or more read-write sequential pages. |
Enums
AdviseAccess | Hint for the access pattern of the underlying mapping. |
AdviseUsage | Hint for the immediacy of accessing the underlying mapping. |
Flush | Desired behavior when flushing write changes. |
Protect | Protection level for a page. |
Functions
allocation_size | Gets a cached version of the system allocation granularity size. |
page_size | Gets a cached version of the system page size. |
Type Definitions
Pgno | Type to represent whole page offsets and counts. |