wasmer icon indicating copy to clipboard operation
wasmer copied to clipboard

Pass a native(rust) struct to Webassembly function/native function

Open Zedonboy opened this issue 3 years ago • 1 comments
trafficstars

Summary

From the examples i can pass value type(numerics), but how do I pass structs value or pointers

Zedonboy avatar May 13 '22 12:05 Zedonboy

https://github.com/wasmerio/wit-bindgen can help with that. Or you can roll it yourself, e.g. serialize the native struct, write the data to wasm memory, pass a pointer to the data to a wrapper function inside wasm, deserialize the data there, call the original function (This is more tricky than it sounds).

jcaesar avatar May 16 '22 03:05 jcaesar