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
impl PolymorphicPermissionCard
Sourcepub fn id(&self) -> CardId
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.
Sourcepub fn parents(&self) -> Vec<CardId>
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.
Sourcepub fn expires_at(&self) -> Option<Timestamp>
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.
Sourcepub fn inspect(&self) -> Result<CardView, PermissionError>
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.
Sourcepub fn derive(
&self,
bounds: &Bounds,
lifespan: Option<&Lifespan>,
) -> Result<PersistentCard, PermissionError>
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.
Sourcepub fn revoke(self) -> Result<u32, PermissionError>
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.
Sourcepub fn install(self, target: &Holder) -> Result<(), PermissionError>
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
impl Debug for PolymorphicPermissionCard
Source§impl<'a> From<&'a PolymorphicPermissionCard> for ScopeParent<'a>
impl<'a> From<&'a PolymorphicPermissionCard> for ScopeParent<'a>
Source§fn from(card: &'a PolymorphicPermissionCard) -> Self
fn from(card: &'a PolymorphicPermissionCard) -> Self
Source§impl FromWire for PolymorphicPermissionCard
impl FromWire for PolymorphicPermissionCard
Source§fn read_wire(reader: &mut WireReader, index: i32) -> Result<Self, WireError>
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.
fn read_result_payload( reader: &mut WireReader, index: Option<i32>, ) -> Result<Self, WireError>
Source§impl IntoWire for PolymorphicPermissionCard
impl IntoWire for PolymorphicPermissionCard
fn preflight(&self, resources: &mut WirePreflight) -> Result<(), WireError>
fn write_wire(&self, writer: &mut WireWriter) -> Result<i32, WireError>
Source§const NEEDS_PREPARATION: bool = true
const NEEDS_PREPARATION: bool = true
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.