pub struct Mmap { /* private fields */ }Expand description
A handle to a memory mapped region.
The region is automatically unmapped when this handle is dropped.
Implementations§
Source§impl Mmap
impl Mmap
Sourcepub const fn into_raw(self) -> (*mut u8, usize)
pub const fn into_raw(self) -> (*mut u8, usize)
Flushes the memory mapped region to disk (if file backed) or ensures visibility. For anonymous mappings, this is generally a no-op or ensures cache coherence.
§Errors
Returns an error if the underlying system call fails.
Currently for anonymous memory this always succeeds.
Requires sys_alloc to expose from_raw parts or similar.
Since Mmap wraps os::MmapInner, we need os::MmapInner to support this too or just handle it here.
Consumes the Mmap and returns the raw pointer and length.
The memory will won’t be unmapped when this struct is dropped.
The caller is responsible for cleaning up the memory, e.g. by
creating a new Mmap with from_raw and dropping it.