Struct mmarinus::Map [−][src]
pub struct Map<T: Type> { /* fields omitted */ }
Expand description
A smart pointer to a mapped region of memory
When this reference is destroyed, munmap()
will be called on the region.
Implementations
Changes the settings of an existing mapping
Upon success, the new mapping “steals” the mapping from the old Map
instance. Using the old instance is a logic error, but is safe.
Changes the permissions of an existing mapping
Upon success, the new mapping “steals” the mapping from the old Map
instance. Using the old instance is a logic error, but is safe.
Split a mapping at the specified offset.
The split address MUST be page-aligned or this call will fail.
Example
use mmarinus::{Kind, Map, perms}; const SIZE: usize = 4 * 1024 * 1024; let map = Map::map(SIZE * 2) .anywhere() .anonymously() .known::<perms::Read>(Kind::Private) .unwrap(); let (l, r) = map.split(SIZE).unwrap(); assert_eq!(l.size(), SIZE); assert_eq!(r.size(), SIZE);
Split a mapping at the specified address.
The address (at
) MUST be page-aligned or this call will fail.
Example
use mmarinus::{Kind, Map, perms}; const SIZE: usize = 4 * 1024 * 1024; let map = Map::map(SIZE * 2) .anywhere() .anonymously() .known::<perms::Read>(Kind::Private) .unwrap(); let at = map.addr() + SIZE; let (l, r) = map.split_at(at).unwrap(); assert_eq!(l.size(), SIZE); assert_eq!(r.size(), SIZE);