This book is about wasm-bindgen
, a Rust library and CLI tool that facilitate high-level interactions between wasm modules and JavaScript. The wasm-bindgen
tool and crate are only one part of the Rust and WebAssembly ecosystem. If you‘re not familiar already with wasm-bindgen
it’s recommended to start by reading the Game of Life tutorial. If you're curious about wasm-pack
, you can find that documentation here.
The wasm-bindgen
tool is sort of half polyfill for features like the host bindings proposal and half features for empowering high-level interactions between JS and wasm-compiled code (currently mostly from Rust). More specifically this project allows JS/wasm to communicate with strings, JS objects, classes, etc, as opposed to purely integers and floats. Using wasm-bindgen
for example you can define a JS class in Rust or take a string from JS or return one. The functionality is growing as well!
Currently this tool is Rust-focused but the underlying foundation is language-independent, and it's hoping that over time as this tool stabilizes that it can be used for languages like C/C++!
Notable features of this project includes:
u32
and floats.With the addition of wasm-pack
you can run the gamut from running Rust on the web locally, publishing it as part of a larger application, or even publishing Rust-compiled-to-WebAssembly on NPM!