Marshalling data in non-JS WASM

I've been looking into using WASM as a backend for plugins in Rust applications, but I've run into some problems. I'm writing both the application and plugins in Rust (the application uses wasmtime to load the WASM; the plugins are no_std cdylibs with target wasm32-unknown-unknown, using wee_alloc to manage memory.)

Transferring data any more complex than an int or float between the application and the plugin is tricky. I have to allocate space in linear memory for the value, then marshal it on one side & unmarshal on the other (and remember to free it.) This is doable, but is a pain since the marshalling has to be written for each type I want to transfer, and the code for the application is different since any pointers have to be recalculated in linear memory. If these plugins were for JS, I could use wasm-bindgen, but I don't know how well that and wasmtime work together (plus, I don't really need JS types specifically, just things like passing strings.)

Is there any standard way of handling this? I've thought about using serde, but I don't know if I'm missing some simpler solution.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.