Skip to main content

Capability

Struct Capability 

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

Sealed capability with HMAC signature

Corresponds to Lean: structure Capability

SECURITY: All fields are pub(crate) to prevent forgery. Capabilities can only be created through kernel operations.

IMPORTANT: signature is RuntimeTag (opaque), NOT SymbolicTag. This prevents key leakage when comparing plugin states.

Implementations§

Source§

impl Capability

Source

pub fn new( id: u128, holder: u128, target: u128, rights: Rights, parent: Option<u128>, epoch: u64, signature: SealedTag, ) -> Result<Capability, CapabilityError>

Create a new capability (kernel-only operation)

Returns Err if invariants violated.

Corresponds to Lean: Capability.WellFormed requirements:

  • h_holder_valid: holder > 0
  • h_rights_nonempty: rights != {}
Source

pub fn payload(&self) -> CapPayload

Extract payload for verification

Corresponds to Lean: def Capability.payload

Source

pub fn id(&self) -> u128

Get the capability ID

Source

pub fn holder(&self) -> u128

Get the holder

Source

pub fn target(&self) -> u128

Get the target

Source

pub fn rights(&self) -> &Rights

Get the rights

Source

pub fn parent(&self) -> Option<u128>

Get the parent capability ID

Source

pub fn epoch(&self) -> u64

Get the epoch

Source

pub fn is_valid(&self) -> bool

Check if the capability is valid (not revoked)

Source

pub fn signature(&self) -> &SealedTag

Get the signature (for verification)

Source

pub fn has_right(&self, right: Right) -> bool

Check if this capability has a specific right

Trait Implementations§

Source§

impl Clone for Capability

Source§

fn clone(&self) -> Capability

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 Debug for Capability

Source§

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

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

impl Eq for Capability

Source§

impl PartialEq for Capability

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Capability

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> Same for T

Source§

type Output = T

Should always be Self
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 = !

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.