Skip to main content

PermissionCard

Struct PermissionCard 

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

A permission card held by the calling component.

The card wraps a host resource handle. It has no public constructor, it cannot be built from a CardId or from data, and it cannot be serialized.

Borrowing operations (id, parents, expires_at, inspect, derive) leave the card in place. Consuming operations (revoke, install) and passing the card as an agent method argument or return value move the host handle out of the card. Every later use of a moved card panics.

Dropping a card releases the caller’s handle. It does not revoke the card and does not remove it from the caller’s wallet.

Decoding a card from an agent method argument or result (FromSchema, FromWire) takes the handle out of the decoded value, so a second decode of the same value fails and two card objects never share one handle. Safe code cannot build such a value without an existing handle. The golem-schema codec handle types expose hidden constructors and accessors that can alias a handle the component already holds, and wit-bindgen’s unsafe resource constructors can name any handle number. Neither path creates authority: the host validates every handle against the component’s own resource table.

Implementations§

Source§

impl PermissionCard

Source

pub fn id(&self) -> CardId

The identifier of this card.

§Panics

Panics if the card was moved. The host traps if the card was revoked or is unknown.

Source

pub fn parents(&self) -> Vec<CardId>

The identifiers of the cards this card was derived from.

§Panics

Panics if the card was moved. The host traps if the card was revoked or is unknown.

Source

pub fn expires_at(&self) -> Option<Timestamp>

The expiry time of this card, or None for a card without a lifespan.

§Panics

Panics if the card was moved. The host traps if the card was revoked or is unknown.

Source

pub fn inspect(&self) -> Result<CardView, PermissionError>

Returns the four grant lists of this card. Requires card:inspect.

§Panics

Panics if the card was moved.

Source

pub fn derive( &self, bounds: &Bounds, lifespan: Option<&Lifespan>, ) -> Result<PersistentCard, PermissionError>

Derives a child card from this card. Requires card:derive.

The positive lists of bounds select the grants of this card that the child retains. The negative lists of bounds are denials that the child adds. The child’s lifespan cannot exceed the lifespan of this card. The host selects the child’s kind, independently of this card’s kind.

§Panics

Panics if the card was moved.

Source

pub fn revoke(self) -> Result<u32, PermissionError>

Revokes this card and every card derived from it. Requires card:revoke.

Returns the number of revoked cards. The card is moved even when the host refuses the revocation.

§Panics

Panics if the card was already moved.

Source

pub fn install(self, target: &Holder) -> Result<(), PermissionError>

Installs this card into the wallet of target. Requires card:install.

The host currently accepts only Holder::Agent targets and refuses account and application targets with PermissionError::NotPermitted. A target that does not match the card’s recipient pattern fails with PermissionError::InstallRecipientMismatch. The card is moved even when the host refuses the installation.

§Panics

Panics if the card was already moved.

Trait Implementations§

Source§

impl Debug for PermissionCard

Source§

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

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

impl<'a> From<&'a PermissionCard> for ScopeParent<'a>

Source§

fn from(card: &'a PermissionCard) -> Self

Converts to this type from the input type.
Source§

impl FromWire for PermissionCard

Source§

fn read_wire(reader: &mut WireReader, index: i32) -> Result<Self, WireError>

Takes the handle out of the decoded node. Decoding the same node again, for example from a second reader over a shared snapshot, fails.

Source§

fn read_result_payload( reader: &mut WireReader, index: Option<i32>, ) -> Result<Self, WireError>

Source§

impl IntoWire for PermissionCard

Source§

fn preflight(&self, resources: &mut WirePreflight) -> Result<(), WireError>

Source§

fn write_wire(&self, writer: &mut WireWriter) -> Result<i32, WireError>

Source§

const NEEDS_PREPARATION: bool = true

False only when prepare_wire is a no-op for every value of this type. Resource preflight still runs regardless of this flag. Custom and derived implementations prepare by default, including those with no stream schema.
Source§

async fn prepare_wire(&self) -> Result<(), WireError>

Wrap native stream endpoints without reading from them. This is called only after the complete value has passed resource preflight.
Source§

fn write_result_payload( &self, writer: &mut WireWriter, ) -> Result<Option<i32>, WireError>

Source§

impl WireSchema for PermissionCard

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

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Resource for T
where T: 'static,

Source§

type Rep = Option<T>

The type which is actually stored in-memory for this resource. 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.
Source§

impl<T> TupleOrUnit<()> for T

Source§

fn into(self)