Skip to main content

SharedRegion

Struct SharedRegion 

Source
pub struct SharedRegion { /* private fields */ }
Expand description

The host’s side of a region, mapped read-write: a sealed memfd on Linux, a POSIX shared memory object unlinked at once on macOS, an unnamed section on Windows.

Implementations§

Source§

impl SharedRegion

Source

pub fn create(len: usize) -> Result<Self>

Makes a region of len bytes, zeroed.

§Errors

When len is zero or the operating system refuses the memory, and on platforms without shared regions (Unsupported).

Source

pub const fn len(&self) -> usize

The region’s length in bytes.

Source

pub const fn is_empty(&self) -> bool

Whether the region holds no bytes, which Self::create refuses.

Source

pub const fn as_mut_slice(&mut self) -> &mut [u8] ⓘ

The region’s bytes.

Source

pub fn descriptor(&self) -> BorrowedFd<'_>

The descriptor to send a worker, which maps it with MappedRegion::open. It cannot resize the region or map it writable, except on Linux before 5.1 (no F_SEAL_FUTURE_WRITE), where only the worker’s read-only mapping keeps it from writing.

Trait Implementations§

Source§

impl Debug for SharedRegion

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Forget for SharedRegion

§

impl Freeze for SharedRegion
where *const u8 is !null: Freeze, I32NotAllOnes: Freeze,

§

impl Move for SharedRegion

§

impl RefUnwindSafe for SharedRegion
where I32NotAllOnes: RefUnwindSafe,

§

impl Send for SharedRegion
where Mapping: Send, I32NotAllOnes: Send,

§

impl Sync for SharedRegion
where Mapping: Sync, I32NotAllOnes: Sync,

§

impl Unpin for SharedRegion
where *const u8 is !null: Unpin, I32NotAllOnes: Unpin,

§

impl UnsafeUnpin for SharedRegion
where *const u8 is !null: UnsafeUnpin, I32NotAllOnes: UnsafeUnpin,

§

impl UnwindSafe for SharedRegion
where NonNull<u8>: UnwindSafe, I32NotAllOnes: UnwindSafe,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.