Skip to main content

Module portable

Module portable 

Source
Expand description

Host-issued capabilities at the native portable boundary.

A portable call moves one Payload: JSON-shaped data plus host-issued capabilities that JSON cannot express. The issuing executor supplies each capability as an opaque Capability backend; this crate never names the executor’s types. Ownership is plain Rust ownership. Dropping the last holder of an issued capability is its close request, so a result that is refused, undelivered or abandoned closes exactly once.

Capabilities never authorize calls by themselves. An Owned handle calls through its own duplicated kernel claim with the ordinary admission checks. The implicit self travels as a Loan that only the issuer can interpret.

A native exporter issues a plain Rust value as a capability of a WIT resource type: the type names its resource type (Issuable), Payload::issue issues the value and places its Slot wherever the result’s data names it, and a method reads its implicit self back as the value through the Receiver of Payload::receiver, or holds it across its awaits with the receiver’s Guard. The value belongs to the object version that issued it, as a compiled exporter’s instance belongs to its Store: it closes with its last owner, and with that version when the exporter is reloaded or released or the host closes, whatever handles remain, once the calls holding it have ended. A method on such a handle then answers as it would for a compiled exporter: Gone/resource from the reloaded exporter, and the kernel’s refusal of the call once the object is released or the host has closed.

A payload may also carry the end of a byte stream (ByteStream). The physical work that produces it never travels in a payload: a provider returns it beside its result in an Outcome, and the call’s own managed task keeps driving it under the call’s invocation.

Structs§

ByteStream
One end of a host-issued byte stream. It is linear: not Clone, and dropping it asks the producer to stop exactly once.
Delivered
A payload result for executors: data, every owned capability, each anchored here, and every stream end, already bound to the calling root by the call. A data-only result allocates no claim and moves its value without conversion; a stream end takes no claim either.
Guard
A method’s self held for the rest of its call, from Receiver::guard: it reads as the value, which it keeps alive while held. It borrows the receiver, which the call took from its payload.
Issued
A capability freshly issued into a payload. It has one owner, and the issuer keeps no strong reference to it.
Loan
The implicit self of one call. The managed call holds its physical owner separately; retaining this weak loan cannot extend the resource’s lifetime.
Moved
One linear move of an existing owner. It retains the exact original admission claim; receiving it creates a new live wrapper, while all aliases of the sender stay revoked. The capability is closed only after this move and any physical borrows have ended.
Nominal
Defining identity of a WIT resource type: its canonical interface and resource name.
Origin
The calling claim of one portable call, as seen by its result decoding.
Outcome
What a portable provider returns: its logical result and, when the call keeps working after publishing it, that physical work.
Owned
An owned WIT resource handle held by native code. Dropping it is the WIT drop. It is not Clone. It closes its capability first and then releases its own admission claim.
Payload
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.
Receiver
The implicit self of one call, read as the value a native exporter issued it from. The call pins the value, so the receiver reads it across awaits within the call. It cannot extend the value’s life: retained beyond the call, it reads while an owner lives and answers Gone/resource once the last owner or the issuing object has closed the value.
Slot
The data slot of a capability issued by Payload::issue. It serializes as the capability’s payload-local index, wherever the result’s data names the resource: the whole result, a record field, a list element, a tuple position, an option, or a variant or result payload.

Traits§

ByteSource
The producing side of one byte stream, supplied by its issuer.
Capability
An issuer’s backend for one capability. Its Drop is the physical close request. Issuers recover their own type from a Loan with Loan::with_backend.
FromPayload
Results of a portable call. Decoding runs inside the provider’s managed call, before the kernel invocation finishes, so ownership exists before delivery can fail.
IntoPayload
Arguments of a portable call: ordinary Serde values, or a payload moved as is.
Issuable
A Rust type whose values a native exporter issues as capabilities of one WIT resource type.