wasmerio / wasmer

🚀 The leading Wasm Runtime supporting WASIX, WASI and Emscripten
https://wasmer.io
MIT License
18.7k stars 802 forks source link

Examples of Rust and other languages compiling to WASM #3579

Open junglie85 opened 1 year ago

junglie85 commented 1 year ago

Summary

Are there any examples where the WebAssembly code is written in Rust rather than WAT? I'm trying to understand how to deal with linear memory, etc, which is covered by the examples, but the WAT does not translate easily or at all to Rust.

I appreciate Wasmer is agnostic of the language that the guest WASM is written in, and some of the implementation details are language specific. However, having the handful of WAT based examples in some common languages like Rust, C, Go, AssemblyScript, etc, would really lower the barrier to entry.

Additional details

Specifically, right now, I'd love an example that shows how to pass a string from a Rust host application into a Rust guest WASM module, append to the string, and return the string and print it to stdout.

sanderpick commented 1 year ago

I was just about to create a similar issue. I think seeing the equivalent Rust code for the WAT in the examples would go a long way to close mental gaps in understanding.