Struct memfile::CreateOptions

source ·
pub struct CreateOptions { /* private fields */ }
Expand description

Options for creating a MemFile.

Support for options depend on platform and OS details. Refer to your OS documentation for memfd_create for more information.

Implementations§

source§

impl CreateOptions

source

pub fn new() -> Self

Get the default creation options for a MemFile.

Initially, file sealing is not enabled and no huge TLB page size is configured.

Note that the close-on-exec flag will always be set on the created file descriptor. If you want to pass it to a child process, you should use libc::dup2 or something similar after forking. Disabling the close-on-exec flag before forking causes a race condition with other threads.

source

pub fn create(&self, name: &str) -> Result<MemFile>

Create a new MemFile` with the current options.

This is a shorthand for MemFile::create. See that function for more details.

source

pub fn create_cstr(&self, name: &CStr) -> Result<MemFile>

Create a new MemFile` with the current options.

This is identical to Self::create, except that it takes the name as CStr to avoid allocations. See MemFile::create for more details.

source

pub fn allow_sealing(self, value: bool) -> Self

Allow sealing operations on the created MemFile.

source

pub fn huge_tlb(self, value: impl Into<Option<HugeTlb>>) -> Self

Create the file in a hugetlbfs filesystem using huge pages for the translation look-aside buffer.

Support for this feature and specific sizes depend on the CPU and kernel configuration. See also: https://www.kernel.org/doc/html/latest/admin-guide/mm/hugetlbpage.html

Trait Implementations§

source§

impl Clone for CreateOptions

source§

fn clone(&self) -> CreateOptions

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 CreateOptions

source§

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

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

impl Default for CreateOptions

source§

fn default() -> CreateOptions

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

impl Copy for CreateOptions

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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

§

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>,

§

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>,

§

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.