0.1.0 • Published 4 years ago
crdts-wasm v0.1.0
rust-crdts wasm
Proof of concept to utilizing the crdts rust crate in Javascript via WebAssembly.
The chief challenge in utilizing crdts via WebAssembly is that wasm-bindgen can't currently handle Rust structures with type parameters (which crdts extensively utilizes).
As such, this proof of concept takes a wrapping approach, building materialized structs for a CRDT / type pair that they can be consumed in JavaScript.
See src/lib.rs for details on how the mechanics of this wrapping work and at index.html for what the JavaScript client looks like.
Running POC Demo
- Install the WASM toolchain for Rust if you haven't already:
$ rustup target add wasm32-unknown-unknown- Install
wasm-packtoolchain:
$ cargo install wasm-pack- Build the demo in WebAssembly using
wasm-pack:
$ wasm-pack build --target web- Start a static webserver in the root of the application:
$ python3 -m http.server- Launch your web browser and navigate to
http://localhost:8000- open your console to see that indeed that the counter is successfully run in JavaScript and outputs a1.
0.1.0
4 years ago