Trait base::mmap::MappedRegion
source · pub unsafe trait MappedRegion: Send + Sync {
// Required methods
fn as_ptr(&self) -> *mut u8;
fn size(&self) -> usize;
// Provided methods
fn add_fd_mapping(
&mut self,
_offset: usize,
_size: usize,
_fd: &dyn AsRawDescriptor,
_fd_offset: u64,
_prot: Protection
) -> Result<()> { ... }
fn remove_mapping(&mut self, _offset: usize, _size: usize) -> Result<()> { ... }
}
Expand description
A range of memory that can be msynced, for abstracting over different types of memory mappings.
§Safety
Safe when implementers guarantee ptr
..ptr+size
is an mmaped region owned by this object that
can’t be unmapped during the MappedRegion
’s lifetime.
Required Methods§
Provided Methods§
sourcefn add_fd_mapping(
&mut self,
_offset: usize,
_size: usize,
_fd: &dyn AsRawDescriptor,
_fd_offset: u64,
_prot: Protection
) -> Result<()>
fn add_fd_mapping( &mut self, _offset: usize, _size: usize, _fd: &dyn AsRawDescriptor, _fd_offset: u64, _prot: Protection ) -> Result<()>
Maps size
bytes starting at fd_offset
bytes from within the given fd
at offset
bytes from the start of the region with prot
protections.
offset
must be page aligned.
§Arguments
offset
- Page aligned offset into the arena in bytes.size
- Size of memory region in bytes.fd
- File descriptor to mmap from.fd_offset
- Offset in bytes from the beginning offd
to start the mmap.prot
- Protection (e.g. readable/writable) of the memory region.