Skip to main content

MmapInner

Struct 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, no_reserve: bool, ) -> Result<MmapInner>

Source

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

Source

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

Source

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

Source

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

Source

pub fn map_anon( len: usize, stack: bool, populate: bool, huge: Option<u8>, no_reserve: bool, ) -> 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 unsafe fn advise( &self, advice: c_int, offset: usize, len: usize, ) -> Result<()>

Perform an madvise().

§Safety

Some advise values can be unsound depending on the situation. It is up to the caller to only perform sound madvise() calls on the memory range.

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

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.