pub struct Cap {
pub target: CapTarget,
pub rights: CapRights,
pub native_mask: Option<NativeMask>,
/* private fields */
}Expand description
Authorization record stored in the runtime Cap table, never in bytecode.
Fields§
§target: CapTarget§rights: CapRights§native_mask: Option<NativeMask>Meaningful only when rights.contains(NATIVE).
Implementations§
Source§impl Cap
impl Cap
Sourcepub fn root(
target: CapTarget,
rights: CapRights,
native_mask: Option<NativeMask>,
cell: &RevocationCell,
) -> Self
pub fn root( target: CapTarget, rights: CapRights, native_mask: Option<NativeMask>, cell: &RevocationCell, ) -> Self
Trusted root mint (runtime / host only). Bytecode cannot call this.
pub fn epoch(&self) -> u64
pub fn is_valid(&self, cell: &RevocationCell) -> bool
Sourcepub fn attenuate(
&self,
want_rights: CapRights,
want_native: Option<&NativeMask>,
) -> Cap
pub fn attenuate( &self, want_rights: CapRights, want_native: Option<&NativeMask>, ) -> Cap
Produce a strictly narrower-or-equal Cap. Never panics, never grants a bit the parent did not have. This is the single choke point the rest of the model sits on — keep it boring and obvious.
§Invariants
rights(result) ⊆ rights(self)(intersect)native(result) ⊆ native(self):(Some(src), Some(want))→src ∩ want(Some(src), None)→ keepsrc(no native change requested)(None, _)→None(cannot invent a mask)
result.epoch == self.epoch— sameRevocationCell; revoke invalidates the whole derivation chain. No fresh cell is minted.
Trait Implementations§
impl Eq for Cap
impl StructuralPartialEq for Cap
Auto Trait Implementations§
impl Freeze for Cap
impl RefUnwindSafe for Cap
impl Send for Cap
impl Sync for Cap
impl Unpin for Cap
impl UnsafeUnpin for Cap
impl UnwindSafe for Cap
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.