Struct rarena_allocator::MmapOptions

source ·
pub struct MmapOptions(/* private fields */);
Available on crate feature 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

source

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();
source

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);
source

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);
source

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();
source

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);
source

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

source§

fn clone(&self) -> MmapOptions

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for MmapOptions

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for MmapOptions

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl From<MmapOptions> for MmapOptions

source§

fn from(opts: Mmap2Options) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more