pub struct MmapInner {
ptr: *mut c_void,
len: usize,
}
Fields§
§ptr: *mut c_void
§len: usize
Implementations§
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
ptr
must point to the start of memory mapping that can be freed usingmunmap(2)
(i.e. returned bymmap(2)
ormremap(2)
)- The memory mapping at
ptr
must have a length oflen + offset
. - If
len + offset == 0
then the memory mapping must be of length 1. offset
must be less than the current page size.
pub fn map( len: usize, file: RawFd, offset: u64, populate: bool, ) -> Result<MmapInner>
pub fn map_exec( len: usize, file: RawFd, offset: u64, populate: bool, ) -> Result<MmapInner>
pub fn map_mut( len: usize, file: RawFd, offset: u64, populate: bool, ) -> Result<MmapInner>
pub fn map_copy( len: usize, file: RawFd, offset: u64, populate: bool, ) -> Result<MmapInner>
pub fn map_copy_read_only( len: usize, file: RawFd, offset: u64, populate: bool, ) -> Result<MmapInner>
sourcepub fn map_anon(
len: usize,
stack: bool,
populate: bool,
huge: Option<u8>,
) -> Result<MmapInner>
pub fn map_anon( len: usize, stack: bool, populate: bool, huge: Option<u8>, ) -> 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
pub fn advise(&self, advice: c_int, offset: usize, len: usize) -> Result<()>
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 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