pub struct Capability {
pub id: [u8; 16],
pub issuer: Did,
pub bearer: Did,
pub scope: Scope,
pub ops: Ops,
pub expiry: Option<u64>,
pub budget_micro_mata: Option<u64>,
pub delegation_depth: u8,
}Expand description
A grant of access from an issuer to a bearer.
Fields§
§id: [u8; 16]Unique grant id (the revocation key).
issuer: DidWho granted this (the owner / a delegating bearer).
bearer: DidWho may use it (a human or an AI agent).
scope: ScopeWhat it applies to.
ops: OpsWhich operations it allows.
expiry: Option<u64>Optional expiry (unix seconds); None = until revoked.
budget_micro_mata: Option<u64>Optional spend cap in micro-$MATA (the metering hook for M8).
delegation_depth: u8How many more times this may be re-delegated (0 = not delegable).
Implementations§
Source§impl Capability
impl Capability
Sourcepub fn grant(
issuer: impl Into<Did>,
bearer: impl Into<Did>,
scope: Scope,
ops: Ops,
) -> Result<Capability, AccessError>
pub fn grant( issuer: impl Into<Did>, bearer: impl Into<Did>, scope: Scope, ops: Ops, ) -> Result<Capability, AccessError>
Mint a fresh capability with a random id, no expiry/budget, non-delegable. Refine with the builder methods.
pub fn with_expiry(self, unix_seconds: u64) -> Capability
pub fn with_budget(self, micro_mata: u64) -> Capability
pub fn with_delegation_depth(self, depth: u8) -> Capability
Trait Implementations§
Source§impl Clone for Capability
impl Clone for Capability
Source§fn clone(&self) -> Capability
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)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Capability
impl Debug for Capability
Source§impl<'de> Deserialize<'de> for Capability
impl<'de> Deserialize<'de> for Capability
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Capability, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Capability, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Capability
Source§impl PartialEq for Capability
impl PartialEq for Capability
Source§impl Serialize for Capability
impl Serialize for Capability
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl StructuralPartialEq for Capability
Auto Trait Implementations§
impl Freeze for Capability
impl RefUnwindSafe for Capability
impl Send for Capability
impl Sync for Capability
impl Unpin for Capability
impl UnsafeUnpin for Capability
impl UnwindSafe for Capability
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