liveBook · Manning

Handle

As explained in Server-Side WebAssembly

A handle is an indirect integer-like value used to refer to a non-copyable resource managed through a resource table.

A handle is an indirect integer-like reference to a non-copyable resource managed in a resource table rather than copied through linear memory. WIT uses handles for resources such as file descriptors or database connections. section 3.1.2 section 2.4

A handle-based interaction proceeds as follows:

  • A component calls an imported function, passing ordinary values such as a key through the component boundary. section 3.1.2
  • The provider creates or accesses a resource and returns an integer-like handle instead of copying the resource itself. section 3.1.2
  • The consumer passes the handle to resource methods, while the resource remains managed in a separate resource table. section 3.1.2

Secret store across isolated components

An application component calls a secret store’s get method with my-key. The store returns a Secret handle; the application then invokes a method on that handle to obtain the secret data. The components retain separate memories, while the interface hides the underlying communication and memory copies. section 3.1.2

Figure 3.2 The interaction between two isolated Wasm components starting from a function call to communicating with an adapter component, doing required memory copies, and returning a resource that can be accessed via a resource table
A screenshot of a computer

AI-generated content may be incorrect.

Trace the call between isolated components, the adapter-mediated memory copies, and the returned resource’s access through a resource table. section 3.1.2

How Server-Side WebAssembly covers it

How deep it goes
Explains handles as resource-table indices and demonstrates method access, but defers deeper resource-table mechanics.
Examples
Uses a secret-store interaction and compares resources with file descriptors or database connections.
What it assumes
Assumes basic WebAssembly memory and interface concepts while introducing non-copyable WIT resources from first principles.
What you can do after
Evaluate/understand how isolated components exchange and invoke operations on non-copyable resources.
How it connects
Connects handles to WebAssembly components, WIT resources, resource tables, linear memory, and interface methods.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Server-Side WebAssembly. The section links point to the parts of the book it draws on.