pub struct Capability { /* private fields */ }Expand description
A specific permission granted to an agent.
Implementations§
Source§impl Capability
impl Capability
Sourcepub fn builder() -> CapabilityBuilder
pub fn builder() -> CapabilityBuilder
Create a new capability builder.
Sourcepub fn id(&self) -> CapabilityId
pub fn id(&self) -> CapabilityId
Get the capability ID.
Sourcepub fn kind(&self) -> &CapabilityKind
pub fn kind(&self) -> &CapabilityKind
Get the capability kind.
Sourcepub fn scope(&self) -> &ResourceScope
pub fn scope(&self) -> &ResourceScope
Get the resource scope.
Sourcepub fn constraints(&self) -> &CapabilityConstraints
pub fn constraints(&self) -> &CapabilityConstraints
Get the constraints.
Sourcepub fn constraints_mut(&mut self) -> &mut CapabilityConstraints
pub fn constraints_mut(&mut self) -> &mut CapabilityConstraints
Get mutable constraints (for usage tracking).
Sourcepub fn grantor(&self) -> &PrincipalId
pub fn grantor(&self) -> &PrincipalId
Get the grantor.
Sourcepub fn granted_at(&self) -> i64
pub fn granted_at(&self) -> i64
Get when this was granted.
Sourcepub fn expires_at(&self) -> Option<i64>
pub fn expires_at(&self) -> Option<i64>
Get when this expires.
Sourcepub fn is_delegatable(&self) -> bool
pub fn is_delegatable(&self) -> bool
Check if this capability is delegatable.
Sourcepub fn max_delegation_depth(&self) -> u32
pub fn max_delegation_depth(&self) -> u32
Get maximum delegation depth.
Sourcepub fn delegation_depth(&self) -> u32
pub fn delegation_depth(&self) -> u32
Get the current delegation depth (0 for root capabilities).
Sourcepub fn parent_capability_id(&self) -> Option<CapabilityId>
pub fn parent_capability_id(&self) -> Option<CapabilityId>
Get the parent capability ID (for delegated capabilities).
Sourcepub fn is_revoked(&self) -> bool
pub fn is_revoked(&self) -> bool
Check if this capability has been revoked.
Sourcepub fn revoked_at(&self) -> Option<i64>
pub fn revoked_at(&self) -> Option<i64>
Get the revocation timestamp if revoked.
Sourcepub fn revocation_reason(&self) -> Option<&str>
pub fn revocation_reason(&self) -> Option<&str>
Get the revocation reason if revoked.
Sourcepub fn lifecycle_state(&self, now_ms: i64) -> CapabilityState
pub fn lifecycle_state(&self, now_ms: i64) -> CapabilityState
Get the lifecycle state at a given time per Section 5.4.
Sourcepub fn is_valid_at(&self, timestamp: i64) -> bool
pub fn is_valid_at(&self, timestamp: i64) -> bool
Check if this capability is valid at a given time.
A capability is valid if it is not revoked and not expired.
Sourcepub fn matches(
&self,
action_kind: &CapabilityKind,
resource: &ResourceId,
) -> bool
pub fn matches( &self, action_kind: &CapabilityKind, resource: &ResourceId, ) -> bool
Check if this capability matches an action.
Sourcepub fn canonical_bytes(&self) -> Vec<u8> ⓘ
pub fn canonical_bytes(&self) -> Vec<u8> ⓘ
Compute the canonical bytes for signing/verification.
Sourcepub fn delegate(
&self,
delegator_key: &SecretKey,
scope: Option<ResourceScope>,
expiry: Option<Duration>,
) -> Result<Capability>
pub fn delegate( &self, delegator_key: &SecretKey, scope: Option<ResourceScope>, expiry: Option<Duration>, ) -> Result<Capability>
Delegate this capability to another agent, creating a child capability.
Enforces:
- INV-CAP-3: child scope must be a subset of parent scope, child expiry must not exceed parent
- INV-CAP-4: delegation depth must not exceed max_delegation_depth
- Rule 5.3.3: delegated capabilities must be a subset of the delegator’s
Trait Implementations§
Source§impl Clone for Capability
impl Clone for Capability
Source§fn clone(&self) -> Capability
fn clone(&self) -> Capability
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
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<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for Capability
impl RefUnwindSafe for Capability
impl Send for Capability
impl Sync for Capability
impl Unpin for Capability
impl UnwindSafe for Capability
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.