No description
- Rust 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .cargo | ||
| crates | ||
| .gitignore | ||
| Cargo.lock | ||
| Cargo.toml | ||
| README.md | ||
| wkg.lock | ||
| wkg.toml | ||
WebAssembly Components Example
Prerequisites
cargo install wasmtime-cli --locked # runtime
cargo install wkg --locked # component dependency resolution
cargo install wac-cli --locked # component linking
Resolve component dependencies
cd crates/format-gcd
wkg fetch # creates wit/deps/...
Build components
cargo build --release
Invoke math-gcd
wasmtime run --invoke "gcd(39, 26)" target/wasm32-wasip2/release/math_gcd.wasm
Invoke format-gcd
First, we need to link the components together to resolve all dependencies.
Here, format_gcd imports interfaces from math_gcd.
wac plug target/wasm32-wasip2/release/format_gcd.wasm \
--plug target/wasm32-wasip2/release/math_gcd.wasm \
-o combined.wasm
Then, we can invoke the combined component.
wasmtime run --invoke "format-gcd(39, 26)" combined.wasm