memfd

Struct Memfd

source
pub struct Memfd { /* private fields */ }
Expand description

An anonymous volatile file, with sealing capabilities.

Implementations§

source§

impl Memfd

source

pub fn try_from_fd<F>(fd: F) -> Result<Self, F>
where F: AsRawFd + IntoRawFd,

Try to convert an object that owns a file descriptor into a Memfd.

This function consumes the ownership of the specified object. If the underlying file-descriptor is compatible with memfd/sealing, a Memfd object is returned. Otherwise the supplied object is returned as error.

source

pub fn try_from_file(file: File) -> Result<Self, File>

Try to convert a File object into a Memfd.

This function consumes the ownership of the specified File. If the underlying file-descriptor is compatible with memfd/sealing, a Memfd object is returned. Otherwise the supplied File is returned for further usage.

source

pub const fn as_file(&self) -> &File

Return a reference to the backing File.

source

pub fn into_file(self) -> File

Convert Memfd to the backing File.

source

pub fn seals(&self) -> Result<SealsHashSet, Error>

Obtain the current set of seals for the Memfd.

source

pub fn add_seal(&self, seal: FileSeal) -> Result<(), Error>

Add a seal to the existing set of seals.

source

pub fn add_seals<'a>( &self, seals: impl IntoIterator<Item = &'a FileSeal>, ) -> Result<(), Error>

Add some seals to the existing set of seals.

Trait Implementations§

source§

impl AsRawFd for Memfd

source§

fn as_raw_fd(&self) -> RawFd

Extracts the raw file descriptor. Read more
source§

impl Debug for Memfd

source§

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

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

impl FromRawFd for Memfd

source§

unsafe fn from_raw_fd(fd: RawFd) -> Self

Convert a raw file-descriptor to a Memfd.

This function consumes ownership of the specified file descriptor. Memfd will take responsibility for closing it when the object goes out of scope.

§Safety

fd must be a valid file descriptor representing a memfd file.

source§

impl IntoRawFd for Memfd

source§

fn into_raw_fd(self) -> RawFd

Consumes this object, returning the raw underlying file descriptor. Read more

Auto Trait Implementations§

§

impl Freeze for Memfd

§

impl RefUnwindSafe for Memfd

§

impl Send for Memfd

§

impl Sync for Memfd

§

impl Unpin for Memfd

§

impl UnwindSafe for Memfd

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