Here are use case examples on using wasm-bridge with wasmtime's component model. Unlike the rest of the documentation, there examples are guaranteed to be up to date, because running them is a part of the CI pipeline.
Setup is a little bit convoluted (to enable sharing built packages between test) and can be seen in the run test script, but here are the basic steps:
- Copy the guest folder somewhere.
- Copy the
guest.rs
file from a test to thesrc
guest folder and rename it tolib.rs
. - In the guest folder, run
cargo component build --target wasm32-unknown-unknown
. - Copy the host folder somewhere.
- Replace the "path" dependency in the host
Cargo.toml
with a current version dependency. - Copy the
host.rs
file from a test to thesrc
host folder. - Make sure the the path in the
lib.rs
host file points to the built component (might need to replacerelease
withdebug
). - Run with
cargo test
in the host folder to verify that it is working.