pub struct RuntimeCap<P>where
P: Permission,{ /* private fields */ }Expand description
A revocable capability token proving the holder has permission P.
Created via RuntimeCap::new, which consumes a Cap<P> as proof of
possession and returns a (RuntimeCap<P>, Revoker) pair.
!Send + !Sync by default — use make_send for
cross-thread transfer. Cloning shares the same revocation state: revoking
one clone revokes all of them.
Implementations§
Source§impl<P> RuntimeCap<P>where
P: Permission,
impl<P> RuntimeCap<P>where
P: Permission,
Sourcepub fn new(_cap: Cap<P>) -> (RuntimeCap<P>, Revoker)
pub fn new(_cap: Cap<P>) -> (RuntimeCap<P>, Revoker)
Creates a revocable capability by consuming a Cap<P> as proof of possession.
Returns a (RuntimeCap<P>, Revoker) pair. The Revoker can invalidate
this capability (and all its clones) from any thread.
Sourcepub fn try_cap(&self) -> Result<Cap<P>, CapSecError>
pub fn try_cap(&self) -> Result<Cap<P>, CapSecError>
Sourcepub fn is_active(&self) -> bool
pub fn is_active(&self) -> bool
Advisory check — returns true if the capability has not been revoked.
The result is immediately stale; do not use for control flow.
Always use try_cap for actual access.
Sourcepub fn make_send(self) -> RuntimeSendCap<P>
pub fn make_send(self) -> RuntimeSendCap<P>
Converts this capability into a RuntimeSendCap that can cross thread boundaries.
This is an explicit opt-in — you’re acknowledging that this capability will be used in a multi-threaded context.
Trait Implementations§
Source§impl<P> Clone for RuntimeCap<P>where
P: Permission,
impl<P> Clone for RuntimeCap<P>where
P: Permission,
Source§fn clone(&self) -> RuntimeCap<P>
fn clone(&self) -> RuntimeCap<P>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more