[][src]Struct sys_util::SharedMemory

pub struct SharedMemory { /* fields omitted */ }

A shared memory file descriptor and its size.

Methods

impl SharedMemory[src]

pub fn new(name: Option<&CStr>) -> Result<SharedMemory>[src]

Creates a new shared memory file descriptor with zero size.

If a name is given, it will appear in /proc/self/fd/<shm fd> for the purposes of debugging. The name does not need to be unique.

The file descriptor is opened with the close on exec flag and allows memfd sealing.

pub fn from_raw_fd<T: IntoRawFd>(fd: T) -> Result<SharedMemory>[src]

Constructs a SharedMemory instance from a file descriptor that represents shared memory.

The size of the resulting shared memory will be determined using File::seek. If the given file's size can not be determined this way, this will return an error.

pub fn get_seals(&self) -> Result<MemfdSeals>[src]

Gets the memfd seals that have already been added to this.

This may fail if this instance was not constructed from a memfd.

pub fn add_seals(&mut self, seals: MemfdSeals) -> Result<()>[src]

Adds the given set of memfd seals.

This may fail if this instance was not constructed from a memfd with sealing allowed or if the seal seal (F_SEAL_SEAL) bit was already added.

pub fn size(&self) -> u64[src]

Gets the size in bytes of the shared memory.

The size returned here does not reflect changes by other interfaces or users of the shared memory file descriptor..

pub fn set_size(&mut self, size: u64) -> Result<()>[src]

Sets the size in bytes of the shared memory.

Note that if some process has already mapped this shared memory and the new size is smaller, that process may get signaled with SIGBUS if they access any page past the new size.

Trait Implementations

impl Into<File> for SharedMemory[src]

impl AsRawFd for SharedMemory[src]

Auto Trait Implementations

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]