Skip to main content

Payload

Struct Payload 

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

The one internal payload of portable calls: data plus capabilities addressed by payload-local indices. A bare number in value names nothing outside this payload.

Implementations§

Source§

impl Payload

Source

pub fn data(value: Value) -> Self

A payload carrying only data.

Source

pub fn value(&self) -> &Value

Source

pub fn map_value(self, map: impl FnOnce(Value) -> Result<Value>) -> Result<Self>

Replace the data in place, keeping every capability.

Source

pub fn attach(&mut self, issued: Issued) -> u32

Attach an owned capability and return its payload-local index for the data slot.

Source

pub fn attach_argument(&mut self, owner: Owned) -> Result<u32>

Move an existing resource into an argument. The caller relinquishes its owner now; refused admission consumes and closes it rather than recreating a Wasm handle.

Source

pub fn attach_moved(&mut self, moved: Moved) -> u32

Attach a move already redeemed by a trusted executor, without duplicating its claim.

Source

pub fn take_arguments(&mut self) -> Vec<Moved>

Consume the typed owned arguments; their data positions are checked by the executor.

Source

pub fn attach_stream(&mut self, stream: ByteStream) -> u32

Attach a stream end and return its payload-local index for the data slot.

Source

pub fn take_receiver(&mut self) -> Option<Loan>

Take the implicit self loan of this call, if any.

Source

pub fn issue<T: Issuable>(&mut self, value: T) -> Slot

Issue a Rust value as a capability of its WIT resource type. Place the returned Slot where the result’s data names the resource, and serialize that result with Payload::encode. The value is this payload’s until the call returns it: then it belongs to the issuing object, and the delivered handle names it.

Source

pub fn encode(self, result: impl Serialize) -> Result<Self>

Replace the data with a serialized result, whose resource positions hold the slots this payload issued.

Source

pub fn receiver<T: Issuable>(&mut self) -> Result<Receiver<T>>

Take the implicit self of this call as the value it was issued from. A call without self is refused, as is a self of another resource type (Forbidden/resource), of another object or a retired revision of the exporter, or one that has closed (Gone/resource).

Source

pub fn receive<T: Issuable>(&self, moved: Moved) -> Result<T>

Receive a moved native value only in its exact issuing object and resource type. Outstanding method guards keep their value alive and prevent exclusive extraction.

Source

pub fn is_data(&self) -> bool

Whether the payload carries no capability at all.

Source

pub fn into_data(self) -> Result<Value>

Return the data of a call to an exporter’s function without self: a self lent to it is refused as a compiled exporter’s function refuses it, Invalid/resource, and any other capability as a data-only boundary refuses it, Invalid/local_value. Refused, they drop and so close.

Trait Implementations§

Source§

impl From<Payload> for Outcome

An ordinary result: the call has physically ended when it returns.

Source§

fn from(payload: Payload) -> Self

Converts to this type from the input type.
Source§

impl IntoPayload for Payload

Auto Trait Implementations§

§

impl !RefUnwindSafe for Payload

§

impl !Send for Payload

§

impl !Sync for Payload

§

impl !UnwindSafe for Payload

§

impl Forget for Payload

§

impl Freeze for Payload
where *const u8 is !null: Freeze, PhantomData<u8>: Freeze, PhantomData<Value>: Freeze, *const LeafNode<String, Value> is !null: Freeze, PhantomData<(Owned, LeafOrInternal)>: Freeze, PhantomData<Box<(String, Value)>>: Freeze, PhantomData<Issued>: Freeze, PhantomData<Moved>: Freeze, *const RcInner<dyn Capability> is !null: Freeze, PhantomData<ByteStream>: Freeze, *const RcInner<Issuer> is !null: Freeze,

§

impl Move for Payload

§

impl Unpin for Payload
where *const u8 is !null: Unpin, *const LeafNode<String, Value> is !null: Unpin, Box<(String, Value)>: Unpin, Rc<dyn Capability>: Unpin, Rc<Reference>: Unpin, *const RcInner<dyn Capability> is !null: Unpin, Rc<RefCell<Shared>>: Unpin, *const RcInner<Issuer> is !null: Unpin,

§

impl UnsafeUnpin for Payload

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, 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.