Crates You Should Know - Rust and WebAssembly (original) (raw)
- 1. Introduction
- 2. Why Rust and WebAssembly?
- 3. Background And Concepts
- 4. Tutorial
- 5. Reference
- 5.1. Crates You Should Know
- 5.2. Tools You Should Know
- 5.3. Project Templates
- 5.4. Debugging
- 5.5. Time Profiling
- 5.6. Shrinking .wasm Size
- 5.7. JavaScript Interoperation
- 5.8. Which Crates Will Work Off-the-Shelf with WebAssembly?
- 5.9. How to Add WebAssembly Support to a General-Purpose Crate
- 5.10. Deploying Rust and WebAssembly to Production
Rust and WebAssembly
This is a curated list of awesome crates you should know about for doing Rust and WebAssembly development.
You can also browse all the crates published to crates.io in the WebAssembly category.
Interacting with JavaScript and the DOM
wasm-bindgen | crates.io | repository
wasm-bindgen
facilitates high-level interactions between Rust and JavaScript. It allows one to import JavaScript things into Rust and export Rust things to JavaScript.
wasm-bindgen-futures | crates.io | repository
wasm-bindgen-futures
is a bridge connecting JavaScript Promise
s and RustFuture
s. It can convert in both directions and is useful when working with asynchronous tasks in Rust, and allows interacting with DOM events and I/O operations.
js-sys | crates.io | repository
Raw wasm-bindgen
imports for all the JavaScript global types and methods, such as Object
, Function
, eval
, etc. These APIs are portable across all standard ECMAScript environments, not just the Web, such as Node.js.
web-sys | crates.io | repository
Raw wasm-bindgen
imports for all the Web's APIs, such as DOM manipulation,setTimeout
, Web GL, Web Audio, etc.
console_error_panic_hook | crates.io | repository
This crate lets you debug panics on wasm32-unknown-unknown
by providing a panic hook that forwards panic messages to console.error
.
console_log | crates.io | repository
This crate provides a backend for the logcrate that routes logged messages to the devtools console.
wee_alloc | crates.io | repository
The Wasm-Enabled, Elfin Allocator. A small (~1K uncompressed.wasm
) allocator implementation for when code size is a greater concern than allocation performance.
Parsing and Generating .wasm Binaries
parity-wasm | crates.io | repository
Low-level WebAssembly format library for serializing, deserializing, and building .wasm
binaries. Good support for well-known custom sections, such as the "names" section and "reloc.WHATEVER" sections.
wasmparser | crates.io | repository
A simple, event-driven library for parsing WebAssembly binary files. Provides the byte offsets of each parsed thing, which is necessary when interpreting relocs, for example.
Interpreting and Compiling WebAssembly
wasmi | crates.io | repository
An embeddable WebAssembly interpreter from Parity.
cranelift-wasm | crates.io | repository
Compile WebAssembly to the native host's machine code. Part of the Cranelift (né Cretonne) code generator project.