This is a little demonstration of Rust compiling to WASM, and using Cap'n Proto messages as a high-bandwidth communication channel between the Rust/WASM code and JavaScript code.
-
Rust (currently a nightly)
-
Cap'n Proto libraries:
- Rustup & Cargo
- cargo-wasm
capnp
tool- Yarn or NPM
- Make
- Your browser of choice supporting JavaScript and WASM
# 1. Install the Rust nightly.
rustup toolchain install nightly
# 2. Install & setup cargo-wasm.
cargo install cargo-wasm
cargo wasm setup
# 3. Clone the repository.
git clone [email protected]:couchand/rust-wasm-capnproto-example.git
cd rust-wasm-capnproto-example
# 4. Install JavaScript dependencies.
yarn
# 5. Build the project.
make
# 6. Pull it up in your browser.
yarn start
Read the code & build config, there's only like 200 lines of code.
I'm new to Rust, so the code's not great. Please submit a PR!