Struct memmap2::os::MmapInner

source ·
pub struct MmapInner {
    ptr: *mut c_void,
    len: usize,
}

Fields§

§ptr: *mut c_void§len: usize

Implementations§

source§

impl MmapInner

source

fn new( len: usize, prot: c_int, flags: c_int, file: RawFd, offset: u64, ) -> Result<MmapInner>

Creates a new MmapInner.

This is a thin wrapper around the mmap system call.

source

fn adjust_mmap_params(len: usize, alignment: usize) -> Result<(usize, usize)>

source

fn as_mmap_params(&self) -> (*mut c_void, usize, usize)

Get the current memory mapping as a (ptr, map_len, offset) tuple.

Note that map_len is the length of the memory mapping itself and not the one that would be passed to from_raw_parts.

source

unsafe fn from_raw_parts(ptr: *mut c_void, len: usize, offset: usize) -> Self

Construct this MmapInner from its raw components

§Safety
  • ptr must point to the start of memory mapping that can be freed using munmap(2) (i.e. returned by mmap(2) or mremap(2))
  • The memory mapping at ptr must have a length of len + offset.
  • If len + offset == 0 then the memory mapping must be of length 1.
  • offset must be less than the current page size.
source

pub fn map( len: usize, file: RawFd, offset: u64, populate: bool, ) -> Result<MmapInner>

source

pub fn map_exec( len: usize, file: RawFd, offset: u64, populate: bool, ) -> Result<MmapInner>

source

pub fn map_mut( len: usize, file: RawFd, offset: u64, populate: bool, ) -> Result<MmapInner>

source

pub fn map_copy( len: usize, file: RawFd, offset: u64, populate: bool, ) -> Result<MmapInner>

source

pub fn map_copy_read_only( len: usize, file: RawFd, offset: u64, populate: bool, ) -> Result<MmapInner>

source

pub fn map_anon( len: usize, stack: bool, populate: bool, huge: Option<u8>, ) -> Result<MmapInner>

Open an anonymous memory map.

source

pub fn flush(&self, offset: usize, len: usize) -> Result<()>

source

pub fn flush_async(&self, offset: usize, len: usize) -> Result<()>

source

fn mprotect(&mut self, prot: c_int) -> Result<()>

source

pub fn make_read_only(&mut self) -> Result<()>

source

pub fn make_exec(&mut self) -> Result<()>

source

pub fn make_mut(&mut self) -> Result<()>

source

pub fn ptr(&self) -> *const u8

source

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

source

pub fn len(&self) -> usize

source

pub fn advise(&self, advice: c_int, offset: usize, len: usize) -> Result<()>

source

pub fn remap(&mut self, new_len: usize, options: RemapOptions) -> Result<()>

source

pub fn lock(&self) -> Result<()>

source

pub fn unlock(&self) -> Result<()>

Trait Implementations§

source§

impl Drop for MmapInner

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl Send for MmapInner

source§

impl Sync for MmapInner

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.