Skip to main content

OwnedWritableCapability

Struct OwnedWritableCapability 

Source
pub struct OwnedWritableCapability<T> { /* private fields */ }
Expand description

RAII wrapper around a WritableCapability<T> that owns the underlying Box<T> allocation and reclaims it on Drop.

Implementations§

Source§

impl<T> OwnedWritableCapability<T>

Source

pub fn new(value: T) -> Self

Heap-allocate value and wrap it in a writable capability.

Source

pub fn from_box(b: Box<T>) -> Self

Wrap an existing Box<T>. Full Read + Write perms.

Source

pub fn cap(&self) -> &WritableCapability<T>

Source

pub fn cap_mut(&mut self) -> &mut WritableCapability<T>

Source

pub fn into_box(self) -> Box<T>

Consume and reclaim the underlying Box.

Methods from Deref<Target = WritableCapability<T>>§

Source

pub const SIGNATURE: AxisMask

Source

pub fn has_permission(&self, p: CapabilityPermission) -> bool

Source

pub fn is_sealed(&self) -> bool

Source

pub fn read(&self) -> Result<T, CapabilityError>
where T: Copy,

Read through the capability.

Source

pub fn write(&mut self, value: T) -> Result<(), CapabilityError>

Write through the capability. The &mut self receiver + the constructor’s &mut [T] / Box-consuming nature provide the unique-writer guarantee.

Source

pub fn narrow( &self, sub_base: usize, sub_length: u32, sub_perms: u32, ) -> Result<Self, CapabilityError>

Narrow to a sub-range, returning a new WritableCapability. To narrow to a read-only view, use narrow_readable.

Source

pub fn narrow_readable( &self, sub_base: usize, sub_length: u32, sub_perms: u32, ) -> Result<ReadableCapability<T>, CapabilityError>

Narrow to a read-only view. Returned ReadableCapability does NOT have Write perm regardless of what sub_perms contains.

Source

pub fn as_readable(&self) -> ReadableCapability<T>

Borrow this WritableCapability as a ReadableCapability view (no Write perm, no transfer of ownership). The borrow checker prevents the writable cap from being used while the readable view is alive.

Trait Implementations§

Source§

impl<T> Deref for OwnedWritableCapability<T>

Source§

type Target = WritableCapability<T>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<T> DerefMut for OwnedWritableCapability<T>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl<T> Drop for OwnedWritableCapability<T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.