In this series of WebAssembly, We are learning about WebAssembly and some of the cool CLI to play with wasm. In this blog, We are going to learn the hosting of our wasm modules in Rust. If you have not been following this series, you can check out the previous blogs related to WebAssemblyWABT and wasm-bindgen  to give you an idea about wasm. Now let’s begin.

Introduction

Till now, you have seen that we have been hosting WebAssembly modules in_web browsers_, but that is not the only way to do so. We can host a wasm module outside a web browser like a Rust program.

We will see how to do it. To do so, we will need a crate called wasmi, but before that, let’s see the qualities of a good host.

Qualities of a Good Host

To be a good host, you need to do all the following things,

1. Load and Validate the wasm Binary

Any application acting as a host is responsible for loading the bytes from that file and validating that all of the preconditions for the raw format of the file are correct.

2. Expose Exports
3. Satisfy Imports
4. Execute the module
5. Module isolation

#rust #hosting #wasm #wasmi #webassembly

Hosting Wasm Modules in Rust Easily using 'wasmi'
1.70 GEEK