0.1.0 • Published 2 years ago

crdts-wasm v0.1.0

Weekly downloads
-
License
-
Repository
-
Last release
2 years ago

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

  1. Install the WASM toolchain for Rust if you haven't already:
$ rustup target add wasm32-unknown-unknown
  1. Install wasm-pack toolchain:
$ cargo install wasm-pack
  1. Build the demo in WebAssembly using wasm-pack:
$ wasm-pack build --target web
  1. Start a static webserver in the root of the application:
$ python3 -m http.server
  1. 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 a 1.