This directory contains example WASM modules implemented with Rust. These examples were used to experiment how we can pass data between runtime and module.
We can't use a Cargo workspace here because we want to build the individual crates for different targets.
Some for wasm32-unknown-unknown
and some for wasm32-wasi
.
Before you run build make sure that you have installed the required targets:
rustup target add wasm32-unknown-unknown
rustup target add wasm32-wasi
Run ./build.sh
to build all modules with the correct target.
./build.sh
The target directory for all modules is set to ./target
(see .cargo/config
), so you'll find the compiled wasm modules in this directory under ./target/
.
The -raw
modules use the method to pass data between host and module described in a blog post of Radu Matei.
The -wasi
modules are compiled with the target wasm32-wasi
and use the standard input and standard output to pass data between host and module.
The k8s-
modules show how to process a Kubernetes TokenReview object.
For this we use the k8s-openapi and serde_json crates.