O'Reilly logo

Programming WebAssembly with Rust by Kevin Hoffman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Building a Console Host Checkers Player

As exciting as it may have been to be able to invoke the add function in one of our earlier WebAssembly modules, eventually writing all of that low-level code is going to feel tedious. As a result, a pattern starts to emerge when we create Rust hosts for WebAssembly modules. This pattern involves:

Creating an Imports Resolver

In wasmi terms, this is an implementation of the ModuleImportResolver trait. Its job is to provide a signature and numeric invocation index for each function imported by the module.

Creating a Runtime for Externals

Each time the host invokes a module function, it has to pass something that implements the Externals trait. This is typically referred to as the runtime, and it’s what ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required