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