pub struct MemoryMappingArena {
addr: *mut u8,
size: usize,
}Expand description
Tracks Fixed Memory Maps within an anonymous memory-mapped fixed-sized arena in the current process.
Fields§
§addr: *mut u8§size: usizeImplementations§
Source§impl MemoryMappingArena
impl MemoryMappingArena
Sourcepub fn new(size: usize) -> Result<MemoryMappingArena>
pub fn new(size: usize) -> Result<MemoryMappingArena>
Sourcepub fn add_anon_protection(
&mut self,
offset: usize,
size: usize,
prot: Protection,
) -> Result<()>
pub fn add_anon_protection( &mut self, offset: usize, size: usize, prot: Protection, ) -> Result<()>
Anonymously maps size bytes at offset bytes from the start of the arena
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.prot- Protection (e.g. readable/writable) of the memory region.
Sourcepub fn add_anon(&mut self, offset: usize, size: usize) -> Result<()>
pub fn add_anon(&mut self, offset: usize, size: usize) -> Result<()>
Anonymously maps size bytes at offset bytes from the start of the arena.
offset must be page aligned.
§Arguments
offset- Page aligned offset into the arena in bytes.size- Size of memory region in bytes.
Sourcepub fn add_fd(
&mut self,
offset: usize,
size: usize,
fd: &dyn AsRawDescriptor,
) -> Result<()>
pub fn add_fd( &mut self, offset: usize, size: usize, fd: &dyn AsRawDescriptor, ) -> Result<()>
Maps size bytes from the start of the given fd at offset bytes from
the start of the arena. 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.
Sourcepub fn add_fd_offset(
&mut self,
offset: usize,
size: usize,
fd: &dyn AsRawDescriptor,
fd_offset: u64,
) -> Result<()>
pub fn add_fd_offset( &mut self, offset: usize, size: usize, fd: &dyn AsRawDescriptor, fd_offset: u64, ) -> Result<()>
Maps size bytes starting at fs_offset bytes from within the given fd
at offset bytes from the start of the arena. 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 offdto start the mmap.
Sourcepub fn add_fd_offset_protection(
&mut self,
offset: usize,
size: usize,
fd: &dyn AsRawDescriptor,
fd_offset: u64,
prot: Protection,
) -> Result<()>
pub fn add_fd_offset_protection( &mut self, offset: usize, size: usize, fd: &dyn AsRawDescriptor, fd_offset: u64, prot: Protection, ) -> Result<()>
Maps size bytes starting at fs_offset bytes from within the given fd
at offset bytes from the start of the arena 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 offdto start the mmap.prot- Protection (e.g. readable/writable) of the memory region.
Sourcefn try_add(
&mut self,
offset: usize,
size: usize,
prot: Protection,
fd: Option<(&dyn AsRawDescriptor, u64)>,
) -> Result<()>
fn try_add( &mut self, offset: usize, size: usize, prot: Protection, fd: Option<(&dyn AsRawDescriptor, u64)>, ) -> Result<()>
Helper method that calls appropriate MemoryMapping constructor and adds the resulting map into the arena.
Trait Implementations§
Source§impl Drop for MemoryMappingArena
impl Drop for MemoryMappingArena
Source§impl From<MemoryMapping> for MemoryMappingArena
impl From<MemoryMapping> for MemoryMappingArena
Source§fn from(mmap: MemoryMapping) -> Self
fn from(mmap: MemoryMapping) -> Self
Source§impl From<MemoryMapping> for MemoryMappingArena
impl From<MemoryMapping> for MemoryMappingArena
Source§fn from(mmap: CrateMemoryMapping) -> Self
fn from(mmap: CrateMemoryMapping) -> Self
Source§impl MappedRegion for MemoryMappingArena
impl MappedRegion for MemoryMappingArena
Source§fn as_ptr(&self) -> *mut u8
fn as_ptr(&self) -> *mut u8
Source§fn 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<()>
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. Read more