minimal-rust-wasm 0.2.0

An extremely minimal Rust + WASM example.
Documentation
  • Coverage
  • 0%
    0 out of 2 items documented0 out of 1 items with examples
  • Size
  • Source code size: 15.92 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.09 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 45s Average build duration of successful builds.
  • all releases: 45s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • tuzz/minimal-rust-wasm
    10 2 1
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • tuzz

Minimal Rust + WASM Example

An extremely minimal Rust + WASM example that works with GitHub pages. It demonstrates how to write to the DOM and how to call a JavaScript function from Rust. Hopefully this will serve as a helpful reference.

Usage

In one tab run:

$ ./bin/setup
$ ./bin/wasm_watch

In another tab run:

$ ./bin/server

If you're not on a Mac, you'll need to install binaryen a different way.

Make a change

Try changing "Hello, world!" to "Hello, foo!" in src/wasm_main.rs. The ./bin/wasm_watch script should automatically rebuild the project and ./bin/server should reload the web page once that's done. Neat!

Deploying

To deploy to GitHub pages run:

$ ./bin/deploy

It will compile the project then copy index.html, target/index.wasm and target/index.js to a tmp/ directory. This is then deployed to the gh-pages branch for the current git repository.

Documentation

Now that you have a working Rust/WASM workflow, refer to the book and the web_sys crate for more information.