Workflow Status Average time to resolve an issue Percentage of issues still open Maintenance

mmarinus

The mmarinus crate wraps the underlying system mmap() call in safe semantics.

For example:

```rust use mmarinus::{Kind, Map, perms};

let mut zero = std::fs::File::open("/dev/zero").unwrap();

let map = Map::map(32) .near(128 * 1024 * 1024) .from(&mut zero, 0) .known::(Kind::Private) .unwrap();

assert_eq!(&*map, &[0; 32]); ```

You can also remap an existing mapping:

```rust use mmarinus::{Kind, Map, perms};

let mut zero = std::fs::File::open("/dev/zero").unwrap();

let mut map = Map::map(32) .anywhere() .from(&mut zero, 0) .known::(Kind::Private) .unwrap();

assert_eq!(&*map, &[0; 32]);

let mut map = map.remap() .from(&mut zero, 0) .known::(Kind::Private) .unwrap();

asserteq!(&*map, &[0; 32]); for i in map.itermut() { i = 255; } assert_eq!(&map, &[255; 32]); ```

Alternatively, you can just change the permissions:

```rust use mmarinus::{Kind, Map, perms};

let mut zero = std::fs::File::open("/dev/zero").unwrap();

let mut map = Map::map(32) .at(128 * 1024 * 1024) .from(&mut zero, 0) .known::(Kind::Private) .unwrap();

assert_eq!(&*map, &[0; 32]);

let mut map = map.reprotect::().unwrap();

asserteq!(&*map, &[0; 32]); for i in map.itermut() { i = 255; } assert_eq!(&map, &[255; 32]); ```

Mapping a whole file into memory is easy:

```rust use mmarinus::{Kind, perms};

let map = Kind::Private.load::("/etc/os-release").unwrap(); ```

License: Apache-2.0