pub struct ReadableCapability<T> { /* private fields */ }Expand description
Read-only bounds-checked capability. The Write permission bit is
silently stripped at construction; no write() method exists.
Layout (24 bytes):
ptr: *const T (8 bytes) - base address
base: usize (8 bytes) - lower bound (often equals ptr)
length: u32 (4 bytes) - bytes from base
perms: u32 (4 bytes) - permission bitmask + sealed bit;
Write bit guaranteed clearedImplementations§
Source§impl<T> ReadableCapability<T>
impl<T> ReadableCapability<T>
Sourcepub const SIGNATURE: AxisMask
pub const SIGNATURE: AxisMask
Direction signature of ReadableCapability<T>. Engages the
K_bounds axis (runtime base / length / permissions stored
at slot for CHERI-style bounds enforcement on every deref).
Sourcepub unsafe fn new(
ptr: *const T,
base: usize,
length: u32,
perms: u32,
) -> Result<Self, CapabilityError>
pub unsafe fn new( ptr: *const T, base: usize, length: u32, perms: u32, ) -> Result<Self, CapabilityError>
§Safety
Caller guarantees [base, base + length) is valid memory for
the lifetime of this capability and ptr lies within that
region. The Write permission bit is silently stripped.
Sourcepub fn from_slice(slice: &[T], perms: u32) -> (ReadableCapability<T>, &[T])
pub fn from_slice(slice: &[T], perms: u32) -> (ReadableCapability<T>, &[T])
Safe constructor: build a read-only capability over a borrowed slice. Write bit silently stripped.
pub fn has_permission(&self, p: CapabilityPermission) -> bool
pub fn is_sealed(&self) -> bool
pub fn sealed(self) -> Self
pub fn unsealed(self) -> Self
Sourcepub fn read(&self) -> Result<T, CapabilityError>where
T: Copy,
pub fn read(&self) -> Result<T, CapabilityError>where
T: Copy,
Read the value through the capability.
Trait Implementations§
Source§impl<T: Clone> Clone for ReadableCapability<T>
impl<T: Clone> Clone for ReadableCapability<T>
Source§fn clone(&self) -> ReadableCapability<T>
fn clone(&self) -> ReadableCapability<T>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl<T: Copy> Copy for ReadableCapability<T>
Auto Trait Implementations§
impl<T> !Send for ReadableCapability<T>
impl<T> !Sync for ReadableCapability<T>
impl<T> Freeze for ReadableCapability<T>
impl<T> RefUnwindSafe for ReadableCapability<T>where
T: RefUnwindSafe,
impl<T> Unpin for ReadableCapability<T>
impl<T> UnsafeUnpin for ReadableCapability<T>
impl<T> UnwindSafe for ReadableCapability<T>where
T: RefUnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more