I'm interested in the potential for using a wasm runtime like wasmtime
(or something similar) to run untrusted user code compiled from Rust. I've read some of the material in the Rust wasm book and some of the documentation for wasmtime and some other crates, and I want to understand better what is possible right now in the ecosystem.
Is it possible right now to create an API of Rust data types and functions that can be used by embedded wasm-compiled Rust?
I see that with wasmtime
I can expose functions from the host to the embedded wasm module, but there doesn't seem to be a facility for translating data types between guest and host beyond the basic wasm integer types. For example, if I wanted to have a custom struct or enum as part of the host-provided API, or even a string, it doesn't look like there's an easy way to do this, and I would need to manually wire up to the linear wasm memory. Is this what the "Interface Types" proposal is for?
Meanwhile it looks like wasm-bindgen
allows for defining these kind of interfaces with custom data types when interacting with JavaScript in the host. Is there an alternative for when the host is Rust? My naive understanding makes me think that should be an easier situation to deal with but maybe not
Thanks for any help anyone can give!