liveBook · Manning

Wasm virtual environment

As explained in Refactoring to Rust

A Wasm virtual environment is an isolated runtime context that supplies the host services required to execute a WebAssembly module.

A Wasm virtual environment is an isolated runtime context that supplies the host services required to execute a WebAssembly module. The WasmEdge SDK lets a Rust CLI define how the module is loaded, configured, and called instead of invoking the WasmEdge binary directly. section 10.4

A typical execution flow is:

  • Find and load the target .wasm file. section 10.4
  • Build the environment and enable WASI host registration. section 10.4
  • Register the module and run an exported function such as static_search or _start. section 10.4

Running a search module

The journal_cli loads paper_search.wasm, constructs a WasmEdge VM, registers the module, and invokes its function. Running cargo run produces the module's output; the CLI supplies execution rather than capturing or manipulating that output. section 10.4

Figure 10.4 Wasm running with SDK
figure

Use the figure to see the Wasm module running through the SDK-provided environment. section 10.4

How Refactoring to Rust covers it

How deep it goes
Traces file loading, WASI configuration, module registration, and function execution, but does not detail the SDK internals.
Examples
Uses journal_cli to load paper_search.wasm and invoke static_search or _start.
What it assumes
Assumes a Rust Cargo project and an available Wasm file, while demonstrating runtime setup from the CLI outward.
What you can do after
Operate/configure a Wasm runtime with the WasmEdge SDK and execute a selected module function from Rust.
How it connects
Connects WebAssembly modules with the WasmEdge SDK, virtual machines, WASI, and Rust Cargo projects.

Related concepts

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