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

Gets the address of the mapping

Gets the size of the mapping

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);

Begin creating a mapping of the specified size

Trait Implementations

Performs the conversion.

Performs the conversion.

Formats the value using the given formatter. Read more

The resulting type after dereferencing.

Dereferences the value.

Mutably dereferences the value.

Executes the destructor for this type. Read more

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.