Diffinery

homeflare/celldpublic

celld/examples/wasm/README.md
28 lines · 982 BRaw History
1# wasm
2
3A Durable Object counter in Rust, compiled to Wasm with
4[workers-rs](https://github.com/cloudflare/workers-rs).
5
6`worker-build` is the workers-rs build tool. It compiles the crate to
7`wasm32-unknown-unknown`, runs wasm-bindgen over the output, and
8writes the JavaScript entry point (`build/worker/shim.mjs`) that
9`wrangler.jsonc` names as `main` — you do not write any JavaScript
10yourself. Install it once, build, and deploy:
11
12```sh
13rustup target add wasm32-unknown-unknown
14cargo install worker-build
15
16worker-build --release
17celld deploy . --bucket s3://my-cells-bucket
18```
19
20```sh
21curl http://localhost:8080/c/hello # {"lang":"rust","n":1,"name":"hello"}
22curl http://localhost:8080/c/hello # n increments — state lives in the cell
23curl http://localhost:8080/c/other # a different cell, its own counter
24```
25
26See [the WebAssembly docs](../../docs/wasm.md) for how celld ships and
27runs the `.wasm` module. Contributed by
28[Connor Hindley](https://github.com/connyay).