Struct base::mmap::MemoryMappingBuilder
source · pub struct MemoryMappingBuilder<'a> {
pub(crate) descriptor: Option<&'a dyn AsRawDescriptor>,
pub(crate) is_file_descriptor: bool,
pub(crate) size: usize,
pub(crate) offset: Option<u64>,
pub(crate) align: Option<u64>,
pub(crate) protection: Option<Protection>,
pub(crate) populate: bool,
}
Fields§
§descriptor: Option<&'a dyn AsRawDescriptor>
§is_file_descriptor: bool
§size: usize
§offset: Option<u64>
§align: Option<u64>
§protection: Option<Protection>
§populate: bool
Implementations§
source§impl<'a> MemoryMappingBuilder<'a>
impl<'a> MemoryMappingBuilder<'a>
Builds a MemoryMapping object from the specified arguments.
sourcepub fn new(size: usize) -> MemoryMappingBuilder<'a>
pub fn new(size: usize) -> MemoryMappingBuilder<'a>
Creates a new builder specifying size of the memory region in bytes.
sourcepub fn from_file(self, file: &'a File) -> MemoryMappingBuilder<'_>
pub fn from_file(self, file: &'a File) -> MemoryMappingBuilder<'_>
Build the memory mapping given the specified File to mapped memory
Default: Create a new memory mapping.
Note: this is a forward looking interface to accomodate platforms that require special handling for file backed mappings.
Build the memory mapping given the specified SharedMemory to mapped memory
Default: Create a new memory mapping.
sourcepub fn offset(self, offset: u64) -> MemoryMappingBuilder<'a>
pub fn offset(self, offset: u64) -> MemoryMappingBuilder<'a>
Offset in bytes from the beginning of the mapping to start the mmap.
Default: No offset
sourcepub fn protection(self, protection: Protection) -> MemoryMappingBuilder<'a>
pub fn protection(self, protection: Protection) -> MemoryMappingBuilder<'a>
Protection (e.g. readable/writable) of the memory region.
Default: Read/write
sourcepub fn align(self, alignment: u64) -> MemoryMappingBuilder<'a>
pub fn align(self, alignment: u64) -> MemoryMappingBuilder<'a>
Alignment of the memory region mapping in bytes.
Default: No alignment
source§impl<'a> MemoryMappingBuilder<'a>
impl<'a> MemoryMappingBuilder<'a>
sourcepub fn populate(self) -> MemoryMappingBuilder<'a>
pub fn populate(self) -> MemoryMappingBuilder<'a>
Request that the mapped pages are pre-populated
Default: Do not populate
sourcepub fn build(self) -> Result<CrateMemoryMapping>
pub fn build(self) -> Result<CrateMemoryMapping>
Build a MemoryMapping from the provided options.
pub(crate) fn wrap( mapping: MemoryMapping, file_descriptor: Option<&'a dyn AsRawDescriptor> ) -> Result<CrateMemoryMapping>
Trait Implementations§
source§impl<'a> MemoryMappingBuilderUnix<'a> for MemoryMappingBuilder<'a>
impl<'a> MemoryMappingBuilderUnix<'a> for MemoryMappingBuilder<'a>
source§fn from_descriptor(
self,
descriptor: &'a dyn AsRawDescriptor
) -> MemoryMappingBuilder<'_>
fn from_descriptor( self, descriptor: &'a dyn AsRawDescriptor ) -> MemoryMappingBuilder<'_>
Build the memory mapping given the specified descriptor to mapped memory
Default: Create a new memory mapping.