liveBook · Manning

Interface

As explained in Refactoring to Rust

An interface is a language construct or component boundary that specifies functionality implementing components must provide.

An interface is a contract for interaction: it names the functionality a component must provide and specifies the parameters and outputs used to call it. A host can call a WebAssembly (Wasm) library through that contract without knowing how the library works. section 10.1

This boundary makes replacement practical. A different Wasm module can fulfill the same interface without changing or stopping the host application. The host still depends on the agreed interface, so its design determines how flexible the integration will be. section 10.1 section 10.4

Calling a module from a Rust CLI

A Rust CLI can register a Wasm file in a WasmEdge VM, then call an exported function such as `static_search` with `params!(0, 1)`. The module must provide the function the host calls; its internal implementation remains separate from the CLI. section 10.4

The same approach can bring existing logic compiled to Wasm into a Rust runtime without incorporating its source into the host build. The module remains a dependency, but it runs in isolation. section 10.4

How Refactoring to Rust covers it

How deep it goes
Defines the contract through parameters and outputs, then shows a WasmEdge function call rather than general Rust interface syntax.
Examples
Uses a Rust CLI that registers a Wasm module and calls its `static_search` function.
What it assumes
Introduces the interface contract while drawing on libraries, executables, and compiled Wasm code.
What you can do after
Apply it via the WasmEdge SDK to call a Wasm module through a host-defined boundary.
How it connects
Connects WebAssembly, WASI, host applications, dependency management, and module isolation.

Also explained in

Compare how 7 books explain interface →

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.