liveBook · Manning

WASI context

As explained in Server-Side WebAssembly

A WASI context is runtime state that stores the WASI resources and configuration made available to a WebAssembly execution.

A WASI context is runtime state that stores the WASI resources and configuration exposed to a WebAssembly execution. In a Wasmtime host, it belongs in application state alongside the WASI resource table. section 4.1

A Rust host configures the context by:

  • Storing WasiCtx and ResourceTable in a State struct. section 4.1
  • Implementing WasiView for context access and IoView for resource-table access. section 4.1
  • Building WasiCtx with inherited standard output, then placing it in a Store. section 4.1
  • Linking WASI before instantiating the component and calling greet. section 4.1

Passing standard output to a component

Create a WasiCtx with WasiCtxBuilder::new().inherit_stdout().build(), construct Store state with that context and a new ResourceTable, and run the component through the linked host. section 4.1

Figure 4.4 Wasmtime/WASI providing access to host capabilities to a Wasm guest
A screen shot of a computer

AI-generated content may be incorrect.

Use the architecture figure to trace how Wasmtime and WASI provide host capabilities to a WebAssembly guest. section 4.1

How Server-Side WebAssembly covers it

How deep it goes
Explains context storage, required traits, output configuration, Store construction, linking, and execution without detailing resource internals.
Examples
Uses a Rust host that inherits standard output and invokes a guest component's greet function.
What it assumes
Assumes Rust, Wasmtime, WASI, and component-host concepts while demonstrating the required host structure and setup.
What you can do after
Operate/configure a Wasmtime host with WASI context, resource-table state, linked capabilities, and inherited standard output.
How it connects
Ties WASI context to Wasmtime, ResourceTable, WasiView, IoView, Linker, Store, and the WebAssembly component model.

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.