Struct vm_memory::mmap::MmapRegionBuilder
source · pub struct MmapRegionBuilder<B = ()> { /* private fields */ }
Expand description
A factory struct to build MmapRegion
objects.
Implementations§
source§impl<B: Bitmap + Default> MmapRegionBuilder<B>
impl<B: Bitmap + Default> MmapRegionBuilder<B>
source§impl<B: Bitmap> MmapRegionBuilder<B>
impl<B: Bitmap> MmapRegionBuilder<B>
sourcepub fn new_with_bitmap(size: usize, bitmap: B) -> Self
pub fn new_with_bitmap(size: usize, bitmap: B) -> Self
Create a new MmapRegionBuilder
using the provided Bitmap
object.
When instantiating the builder for a region that does not require dirty bitmap
bitmap tracking functionality, we can specify a trivial Bitmap
implementation
such as ()
.
sourcepub fn with_mmap_prot(self, prot: i32) -> Self
pub fn with_mmap_prot(self, prot: i32) -> Self
Create the MmapRegion
object with the specified mmap memory protection flag prot
.
sourcepub fn with_mmap_flags(self, flags: i32) -> Self
pub fn with_mmap_flags(self, flags: i32) -> Self
Create the MmapRegion
object with the specified mmap flags
.
sourcepub fn with_file_offset(self, file_offset: FileOffset) -> Self
pub fn with_file_offset(self, file_offset: FileOffset) -> Self
Create the MmapRegion
object with the specified file_offset
.
sourcepub fn with_hugetlbfs(self, hugetlbfs: bool) -> Self
pub fn with_hugetlbfs(self, hugetlbfs: bool) -> Self
Create the MmapRegion
object with the specified hugetlbfs
flag.
sourcepub unsafe fn with_raw_mmap_pointer(self, raw_ptr: *mut u8) -> Self
pub unsafe fn with_raw_mmap_pointer(self, raw_ptr: *mut u8) -> Self
Create the MmapRegion
object with pre-mmapped raw pointer.
§Safety
To use this safely, the caller must guarantee that raw_addr
and self.size
define a
region within a valid mapping that is already present in the process.
sourcepub fn build(self) -> Result<MmapRegion<B>, Error>
pub fn build(self) -> Result<MmapRegion<B>, Error>
Build the MmapRegion
object.