pub struct MmapInner {
ptr: *mut c_void,
len: usize,
}Fields§
§ptr: *mut c_void§len: usizeImplementations§
Source§impl MmapInner
impl MmapInner
Sourcefn new(
len: usize,
prot: c_int,
flags: c_int,
file: RawFd,
offset: u64,
) -> Result<MmapInner>
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.
fn adjust_mmap_params(len: usize, alignment: usize) -> Result<(usize, usize)>
Sourcefn as_mmap_params(&self) -> (*mut c_void, usize, usize)
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.
Sourceunsafe fn from_raw_parts(ptr: *mut c_void, len: usize, offset: usize) -> Self
unsafe fn from_raw_parts(ptr: *mut c_void, len: usize, offset: usize) -> Self
Construct this MmapInner from its raw components
§Safety
ptrmust point to the start of memory mapping that can be freed usingmunmap(2)(i.e. returned bymmap(2)ormremap(2))- The memory mapping at
ptrmust have a length oflen + offset. - If
len + offset == 0then the memory mapping must be of length 1. offsetmust be less than the current page size.
pub fn map( len: usize, file: RawFd, offset: u64, populate: bool, no_reserve: bool, ) -> Result<MmapInner>
pub fn map_exec( len: usize, file: RawFd, offset: u64, populate: bool, no_reserve: bool, ) -> Result<MmapInner>
pub fn map_mut( len: usize, file: RawFd, offset: u64, populate: bool, no_reserve: bool, ) -> Result<MmapInner>
pub fn map_copy( len: usize, file: RawFd, offset: u64, populate: bool, no_reserve: bool, ) -> Result<MmapInner>
pub fn map_copy_read_only( len: usize, file: RawFd, offset: u64, populate: bool, no_reserve: bool, ) -> Result<MmapInner>
Sourcepub fn map_anon(
len: usize,
stack: bool,
populate: bool,
huge: Option<u8>,
no_reserve: bool,
) -> Result<MmapInner>
pub fn map_anon( len: usize, stack: bool, populate: bool, huge: Option<u8>, no_reserve: bool, ) -> Result<MmapInner>
Open an anonymous memory map.
pub fn flush(&self, offset: usize, len: usize) -> Result<()>
pub fn flush_async(&self, offset: usize, len: usize) -> Result<()>
fn mprotect(&mut self, prot: c_int) -> Result<()>
pub fn make_read_only(&mut self) -> Result<()>
pub fn make_exec(&mut self) -> Result<()>
pub fn make_mut(&mut self) -> Result<()>
pub fn ptr(&self) -> *const u8
pub fn mut_ptr(&mut self) -> *mut u8
pub fn len(&self) -> usize
Sourcepub unsafe fn advise(
&self,
advice: c_int,
offset: usize,
len: usize,
) -> Result<()>
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.
pub fn remap(&mut self, new_len: usize, options: RemapOptions) -> Result<()>
pub fn lock(&self) -> Result<()>
pub fn unlock(&self) -> Result<()>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for MmapInner
impl RefUnwindSafe for MmapInner
impl Unpin for MmapInner
impl UnsafeUnpin for MmapInner
impl UnwindSafe for MmapInner
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more