Skip to main content

CapabilityBit

Enum CapabilityBit 

Source
#[repr(u32)]
pub enum CapabilityBit { ReadsFs = 0, WritesFs = 1, Network = 2, ReadsClock = 3, ReadsEnv = 4, UsesRng = 5, }
Expand description

Canonical assignment of capability bits to stable bit positions.

Each variant’s discriminant is the bit index the compiled backends key on: the cranelift CapabilityVtable slots a host fn at cap_bit, the LLVM / wasm host boundaries consult the same index, and the wasm __relon_check_cap import receives it. Hosts registering a #native function tag the registration with the matching bit.

Discriminants are stable: adding a new capability appends a new variant rather than reshuffling existing values, so previously emitted modules keep validating against the same bit positions.

Variants§

§

ReadsFs = 0

Filesystem reads. Mirrors Capabilities::reads_fs / NativeFnGate::reads_fs.

§

WritesFs = 1

Filesystem writes. Mirrors Capabilities::writes_fs / NativeFnGate::writes_fs.

§

Network = 2

Network access (sockets, HTTP, DNS). Mirrors Capabilities::network / NativeFnGate::network.

§

ReadsClock = 3

Wall / monotonic clock reads. Mirrors Capabilities::reads_clock / NativeFnGate::reads_clock.

§

ReadsEnv = 4

Process environment reads. Mirrors Capabilities::reads_env / NativeFnGate::reads_env.

§

UsesRng = 5

Random-number / non-deterministic source reads. Mirrors Capabilities::uses_rng / NativeFnGate::uses_rng.

Implementations§

Source§

impl CapabilityBit

Source

pub fn bit_index(self) -> u32

Stable bit index this capability claims. Used by the cranelift vtable and LLVM / wasm host-boundary checks to key the same capability across backends.

Source

pub fn as_str(self) -> &'static str

Stable, audit-visible string label for this capability. Mirrors the NativeFnGate::missing_bits field-name strings so historical diagnostics keep the same wording.

Source

pub fn deny_message(self) -> String

Human-readable denial message for the reason field of RuntimeError::CapabilityDenied. The dominant (and only Capabilities-produced) case: the fn declared this bit but the caller never granted it.

Trait Implementations§

Source§

impl Clone for CapabilityBit

Source§

fn clone(&self) -> CapabilityBit

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for CapabilityBit

Source§

impl Debug for CapabilityBit

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for CapabilityBit

Source§

impl PartialEq for CapabilityBit

Source§

fn eq(&self, other: &CapabilityBit) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for CapabilityBit

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.