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
impl Mmap
Sourcepub unsafe fn from_raw(mem: *mut [u8]) -> Self
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.
Sourcepub unsafe fn split_at(self, offset: usize) -> (Self, Self)
pub unsafe fn split_at(self, offset: usize) -> (Self, Self)
Splits the memory mapping into two sub-mappings:
- from zero included to
offsetexcluded, and - from
offsetincluded 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.