Struct mmap_fixed::MemoryMap

source ·
pub struct MemoryMap { /* private fields */ }
Expand description

A memory mapped file or chunk of memory. This is a very system-specific interface to the OS’s memory mapping facilities (mmap on POSIX, VirtualAlloc/CreateFileMapping on Windows). It makes no attempt at abstracting platform differences, besides in error values returned. Consider yourself warned.

The memory map is released (unmapped) when the destructor is run, so don’t let it leave scope by accident if you want it to stick around.

Implementations§

source§

impl MemoryMap

source

pub fn new(min_len: usize, options: &[MapOption]) -> Result<MemoryMap, MapError>

Create a new mapping with the given options, at least min_len bytes long. min_len must be greater than zero; see the note on ErrZeroLength.

source

pub fn granularity() -> usize

Granularity that the offset or address must be for MapOffset and MapAddr respectively.

source§

impl MemoryMap

source

pub fn data(&self) -> *mut u8

Returns the pointer to the memory created or modified by this map.

source

pub fn len(&self) -> usize

Returns the number of bytes this map applies to.

source

pub fn kind(&self) -> MemoryMapKind

Returns the type of mapping this represents.

Trait Implementations§

source§

impl Drop for MemoryMap

source§

fn drop(&mut self)

Unmap the mapping. Panics the task if munmap panics.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.