Skip to main content

encode_value

Function encode_value 

Source
pub fn encode_value(value: &SchemaValue) -> Result<SchemaValueTree, EncodeError>
Expand description

Encode a value tree on a guest, transferring each SchemaValue::QuotaToken owned handle into the wire tree as a quota-token-handle node.

A guest holds quota tokens as opaque, affine owned handles. Lowering a value that contains a token moves the underlying own<quota-token> resource into the wire tree (first encode wins); after this the originating SchemaValue / SDK token wrapper is empty.

A preflight pass runs first so that an aliased handle (the same token appearing twice) or an already-consumed handle is reported (EncodeError::AliasedQuotaTokenHandle / EncodeError::QuotaTokenAlreadyConsumed) before any handle is moved, so a failed encode never destroys a still-valid token.