Chapter 9: Crossing the Boundary between Rust and WebAssembly

So far, we have only seen examples of sharing simple numbers between JavaScript and WebAssembly. In the last section, we saw how wasm-bindgen helps to pass a string from Rust to JavaScript with ease. In this chapter, we will explore how wasm-bindgen makes it easier to convert more complex data types between JavaScript and WebAssembly via Rust. We will cover the following sections in this chapter:

  • Sharing classes from Rust with JavaScript
  • Sharing classes from JavaScript with Rust
  • Calling the JavaScript API via WebAssembly
  • Calling closures via WebAssembly
  • Importing the JavaScript function into Rust
  • Calling a web API via WebAssembly

Technical requirements

You can find the code files ...

Get Practical WebAssembly now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.