-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add an alternative to Result<T, JsValue> for the wasm32-wasi target #2414
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
In general wasm-bindgen was never designed for anything other than the web. Bits and pieces of it happen to work on wasm32-wasi but at a fundamental level it's not really going to work well there. I think wasm-bindgen probably isn't the right tool for the job for wasi and native wasm interop with a host at this point. Systems like interface types show much more promise in this regard. It's likely that Rust will gain tooling for interface types in the future and wasm-bindgen will be reimplemented on top of that. Until then though I wouldn't recommend using wasm-bindgen for an out-of-browser runtime like Wasmtime. |
Yep yep, aware of the interface types too and was wondering whether wasm-bindgen would be implemented on top of that and then be compatible for other runtimes such as |
FYI as this issue is recent, I'm just learning and wanted to use WASI in the browser with WasmerJS, and have managed to make use of wasm-bindgen to simplify handling of bindings. Reading the above I wonder what will and won't work with this approach. I've been collecting examples using wasm-bindgen to probe the limits but there aren't many out there. The ones I found in the wasm-bindgen book are incomplete and I'm not sure if my failure to get them working is my lack of understanding or because the issues mentioned above (e.g. see this issue). Pointers to more examples welcome, and if you are interested in using WasmerJS with wasm-bindgen, or have comments that will help me understand the usefulness of this approach let me know. The demo project is: https://github.com/happybeing/svelte-wasi-with-rust |
When returning Result type we must use JsValue as the type to hold error cases. JsValue isn't supported on the wasm32-wasi target, if attempting to build for cranelift (eg. for use with wasmtime).
It would be nice to have use a supported interface type for the error value that works in both
wasm32-unknown-unknown
andwasm32-wasi
targets.The text was updated successfully, but these errors were encountered: