pub struct SharedMemory { /* private fields */ }
Expand description
A shared memory file descriptor and its size.
Implementations§
Sourcepub fn new(name: Option<&CStr>) -> Result<SharedMemory>
pub fn new(name: Option<&CStr>) -> Result<SharedMemory>
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.
Sourcepub fn from_raw_fd<T: IntoRawFd>(fd: T) -> Result<SharedMemory>
pub fn from_raw_fd<T: IntoRawFd>(fd: T) -> Result<SharedMemory>
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.
Sourcepub fn get_seals(&self) -> Result<MemfdSeals>
pub fn get_seals(&self) -> Result<MemfdSeals>
Gets the memfd seals that have already been added to this.
This may fail if this instance was not constructed from a memfd.
Sourcepub fn add_seals(&mut self, seals: MemfdSeals) -> Result<()>
pub fn add_seals(&mut self, seals: MemfdSeals) -> Result<()>
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.