Skip to main content

PolymorphicPermissionCard

Struct PolymorphicPermissionCard 

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

A template permission card held by the calling component.

The grants of a template card may contain slot variables, such as ?agent or ?env in an owner, which the host resolves for each holder. The agent’s initial card is a template card. wallet returns template cards as WalletCard::Template.

A template card follows the same rules as a PermissionCard: it has no public constructor, it cannot be built from a CardId or from data, it cannot be serialized, and revoke, install and passing it as an agent method argument or return value move its host handle. Every later use of a moved card panics.

The SDK offers no conversion between a template card and a PermissionCard. derive returns the persistent kind selected by the host. As an agent method parameter or result, this type declares a permission-card with polymorphic: true, and a PermissionCard declares polymorphic: false. The host refuses an agent method input or output whose card does not match the declared kind. The guest codecs see only the handle: a decoded card takes the type that the decoder declares.

Implementations§

Source§

impl PolymorphicPermissionCard

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, with their slot variables. 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 persistent child card from this card. Requires card:derive.

The host first resolves this template card for the caller, so this card must be in the caller’s wallet. The bounds then apply as in PermissionCard::derive.

§Panics

Panics if the card was moved.

Source

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

Revokes this card and every card derived from it, as PermissionCard::revoke does. Requires card:revoke.

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, as PermissionCard::install does. Requires card:install.

The host resolves the template for target and installs the resolved card; the template card stays in the caller’s wallet. The handle is moved even when the host refuses the installation.

§Panics

Panics if the card was already moved.

Trait Implementations§

Source§

impl Debug for PolymorphicPermissionCard

Source§

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

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

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

Source§

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

Converts to this type from the input type.
Source§

impl FromWire for PolymorphicPermissionCard

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 PolymorphicPermissionCard

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 PolymorphicPermissionCard

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)