Struct rarena_allocator::MmapOptions
source · pub struct MmapOptions(/* private fields */);memmap and non-target_family="wasm" only.Expand description
A memory map options for file backed SkipMap,
providing advanced options and flags for specifying memory map behavior.
Implementations§
source§impl MmapOptions
impl MmapOptions
sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new set of options for configuring and creating a memory map.
§Example
use rarena_allocator::MmapOptions;
// Create a new memory map options.
let mut mmap_options = MmapOptions::new();sourcepub fn len(self, len: u32) -> Self
pub fn len(self, len: u32) -> Self
Configures the created memory mapped buffer to be len bytes long.
This option is mandatory for anonymous memory maps.
For file-backed memory maps, the length will default to the file length.
§Example
use rarena_allocator::MmapOptions;
let opts = MmapOptions::new().len(9);sourcepub fn offset(self, offset: u32) -> Self
pub fn offset(self, offset: u32) -> Self
Configures the memory map to start at byte offset from the beginning of the file.
This option has no effect on anonymous memory maps.
By default, the offset is 0.
§Example
use rarena_allocator::MmapOptions;
let opts = MmapOptions::new().offset(30);sourcepub fn stack(self) -> Self
pub fn stack(self) -> Self
Configures the anonymous memory map to be suitable for a process or thread stack.
This option corresponds to the MAP_STACK flag on Linux. It has no effect on Windows.
This option has no effect on file-backed memory maps.
§Example
use rarena_allocator::MmapOptions;
let stack = MmapOptions::new().stack();sourcepub fn huge(self, page_bits: Option<u8>) -> Self
pub fn huge(self, page_bits: Option<u8>) -> Self
Configures the anonymous memory map to be allocated using huge pages.
This option corresponds to the MAP_HUGETLB flag on Linux. It has no effect on Windows.
The size of the requested page can be specified in page bits. If not provided, the system default is requested. The requested length should be a multiple of this, or the mapping will fail.
This option has no effect on file-backed memory maps.
§Example
use rarena_allocator::MmapOptions;
let stack = MmapOptions::new().huge(Some(21)).len(2*1024*1024);sourcepub fn populate(self) -> Self
pub fn populate(self) -> Self
Populate (prefault) page tables for a mapping.
For a file mapping, this causes read-ahead on the file. This will help to reduce blocking on page faults later.
This option corresponds to the MAP_POPULATE flag on Linux. It has no effect on Windows.
§Example
use rarena_allocator::MmapOptions;
let opts = MmapOptions::new().populate();Trait Implementations§
source§impl Clone for MmapOptions
impl Clone for MmapOptions
source§fn clone(&self) -> MmapOptions
fn clone(&self) -> MmapOptions
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for MmapOptions
impl Debug for MmapOptions
source§impl Default for MmapOptions
impl Default for MmapOptions
source§impl From<MmapOptions> for MmapOptions
impl From<MmapOptions> for MmapOptions
source§fn from(opts: Mmap2Options) -> Self
fn from(opts: Mmap2Options) -> Self
Auto Trait Implementations§
impl Freeze for MmapOptions
impl RefUnwindSafe for MmapOptions
impl Send for MmapOptions
impl Sync for MmapOptions
impl Unpin for MmapOptions
impl UnwindSafe for MmapOptions
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more