wasmerio / wai

A language binding generator for `wai` (a precursor to WebAssembly interface types)
Apache License 2.0
116 stars 13 forks source link

WebAssembly Component Model + WASI #36

Open eliabieri opened 1 year ago

eliabieri commented 1 year ago

Is there currently a way of running a WebAssembly component with WASMER that uses WASI? The wai-component tool seems to be able to generate a component from a core WebAssembly module and a corresponding .wai interface file.

What I didn't find is an example demonstrating how WASMER, embedded into Rust, can load a .wai file and the WebAssembly component and run functions exposed in the .wai definition.

Michael-F-Bryan commented 1 year ago

The wai-component tool is something different and not really a part of the WAI project.

What you are looking for are the wai-bindgen-rust crate for creating a WebAssembly module that implements a *.wai file's interface and the wai-bindgen-wasmer crate for using Wasmer to load that WebAssembly module. Their relationship is covered briefly in the Wasmer Pack docs.

Loading WASI executables isn't normally an issue. You just need to use WasiEnv from the wasmer-wasi crate to provide WASI imports when instantiating the WebAssembly module.