What's the latest recommendation and best practice for passing anything other than integers between the host and the WASM guest? Is the trick of passing a pointer and a length in the guest's memory still the best? Or perhaps handling the guest's stdin and stdout using WASI? Or something else?
How should data be formatted? Perhaps using BSON? I'll definitely need to pass strings and arrays of strings, and perhaps structs too.
The latest recommendation here would be to use the component model, which supports complex data types: https://component-model.bytecodealliance.org/design/wit.html
Thank you Lann. Does this exist for Go?
Is there anything like Extism for Wasmtime?
wit-bindgen
can create bindings for tinygo: https://github.com/bytecodealliance/wit-bindgen/?tab=readme-ov-file#guest-tinygo
I believe mainline go is WIP, but they don't allow go programs to export arbitrary functions at the wasm level, which is a bit of a blocker IIUC
also fwiw, it seems like extism is built on top of wasmtime: https://github.com/extism/extism/blob/9aa817def7a1616629e30862c93d9ec68f774f7c/runtime/Cargo.toml#L12
Thank you fitzgen, I'll take a look at these.
The other thing I was thinking of doing was open two named pipes using mkfifo() in WASI, one for each direction, and passing BSON or JSON messages between host and guest using them. Has anyone tried this?
Of course doing this would require having file access in WASI working, which I haven't yet managed in Wasmtime (see my "Writing files using WASI PreopenDir()" post).
Last updated: Nov 22 2024 at 16:03 UTC