Here are use case examples on using wasm-bridge with wasmtime's component model including the WASI interface. 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.rsfile from a test to thesrcguest folder and rename it tolib.rs. - In the guest folder, run
cargo component build. - Copy the host folder somewhere.
- Replace the "path" dependency in the host
Cargo.tomlwith a current version dependency. - Copy the
host.rsfile from a test to thesrchost folder. - Make sure the the path in the
lib.rshost file points to the built component (might need to replacereleasewithdebug). - Run with
cargo testin the host folder to verify that it is working.