Mmap

Struct Mmap 

Source
pub struct Mmap { /* private fields */ }
Expand description

A memory mapping that was mapped application using mmap. munmap is automatically called when the object is dropped.

§Invariants

The address in mem must be a multiple of the PAGE_SIZE and of the mapping’s huge page size if the mapping employs huge pages.

mem’s length must not be zero.

Implementations§

Source§

impl Mmap

Source

pub unsafe fn from_raw(mem: *mut [u8]) -> Self

Creates a new Mmap object from a slice that was mapped with mmap.

§Safety

The address in mem must be a multiple of the PAGE_SIZE and of the mapping’s huge page size if the mapping employs huge pages.

mem’s length must not be zero.

Source

pub unsafe fn split_at(self, offset: usize) -> (Self, Self)

Splits the memory mapping into two sub-mappings:

  1. from zero included to offset excluded, and
  2. from offset included to the end.
§Safety

offset must be a multiple of the PAGE_SIZE and of the mapping’s huge page size if the mapping employs huge pages.

offset must not be zero or be larger than or equal to the mapping’s size as empty (sub-)mappings are invalid according to Mmap’s invariants.

Source

pub fn into_raw(self) -> *mut [u8]

Consumes the Mmap, returning a wrapped raw pointer.

After calling this function, the caller is responsible for the memory mapping.

Trait Implementations§

Source§

impl AsMut<[u8]> for Mmap

Source§

fn as_mut(&mut self) -> &mut [u8]

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl AsRef<[u8]> for Mmap

Source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Drop for Mmap

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for Mmap

Source§

impl Sync for Mmap

Auto Trait Implementations§

§

impl Freeze for Mmap

§

impl RefUnwindSafe for Mmap

§

impl Unpin for Mmap

§

impl UnwindSafe for Mmap

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>,

Source§

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>,

Source§

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.