Skip to content

How to pass JS types as params when embedding wasmi #723

Answered by huntc
huntc asked this question in Q&A
Discussion options

You must be logged in to vote

Well, I spent quite a bit of this week learning how to pass complex types around between a WASMI host written in Rust, and a Rust based WASM program using the component model.

I won.

The approach I took:

  1. Create a project using wit-bindgen as documented. Quite straightforward, and I ended up declaring two worlds in my wit file - one for exporting by the wasm, and one for importing elsewhere.
  2. Create a Rust project for importing the wit.
  3. In my Rust/wasmi host, I import the project from (2) and I'm then free to use the wit-bindgen-generated types.
  4. Expand the macro generated code from the project (2) and transpose it to my host program for the purposes of modifying it. wit-bindgen isn't ready…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@huntc
Comment options

Answer selected by Robbepop
@Robbepop
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants