Load a wasm module in rust

Merry Christmas to y'all :christmas_tree:

TL,DR: How to get a wasm instance inside wasm?

I'm trying to load a wasm 'plugin' inside another wasm module, both written in rust. To that end, I created a small PoC project with the 'main' wasm app, a 'plugin' wasm app and a simple webserver.

Fortunately the js_sys crate provides me with a tool to fetch and parse wasm binary code. However I cannot access the module or the instance generated by this call. Via the log, I can see, the return type is a JsValue containing an object which matches the specification. I already tried to use serde, but Module and Instance from the js_sys crate are not Deserializable.

It seems, that the behaviour can be accomplished by using a JS wrapper, but I'd like to create a solution entirely in rust.

Please see the code below:

Turns out wasm-bindgen provides quite elaborate examples, if you know what to look for :smiley:
https://rustwasm.github.io/wasm-bindgen/examples/wasm-in-wasm.html

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.