1 unstable release

0.2.0 Jun 23, 2020

#670 in WebAssembly

MIT license

15KB
318 lines

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.

Dependencies

~7.5–10MB
~182K SLoC

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy