HillOfTong opened issue #10848:
I'm not sure the best place to ask this type of question. If it's no, just let me know where and I'll ask there.
I am trying to use WASM in my Cpp project and i found this project wasmtime. And in my project, I plan to use rust to write WSAM code.
There are some questions:
- How to define Memory type, Table type in rust which used in test wat files. There's only WAT file used in test case.
- If i can't define Memory type, Table type in rust. Is there a approach to exchange complex struct between cpp and rust? I noticed that it seems the only way is to copy (byte by byte) data between WSAM liner memory and cpp memory.
bjorn3 commented on issue #10848:
Using the wasm component model would be the canonical answer. I'm not sure if Wasmtime supports using it directly from C++ already though: https://github.com/bytecodealliance/wasmtime/issues/8036
alexcrichton closed issue #10848:
I'm not sure the best place to ask this type of question. If it's no, just let me know where and I'll ask there.
I am trying to use WASM in my Cpp project and i found this project wasmtime. And in my project, I plan to use rust to write WSAM code.
There are some questions:
- How to define Memory type, Table type in rust which used in test wat files. There's only WAT file used in test case.
- If i can't define Memory type, Table type in rust. Is there a approach to exchange complex struct between cpp and rust? I noticed that it seems the only way is to copy (byte by byte) data between WSAM liner memory and cpp memory.
alexcrichton commented on issue #10848:
Indeed yes the answer to this is the component model. Work is ongoing to expose a C API for the component model, and if you're up for it building out the C++ headers that use the C API I think would be reasonable as well, that's not been done yet.
Otherwise also of note is that linear memory languages like Rust do not have direct ways to model memories/tables/WebAssembly constructs. LLVM's compilation model maps to WebAssembly, but Rust does not have native support for these constructs. That means that if you're not using the component model then, yes, you'll have to serialize information into linear memory and the host would have to deserialize that information from linear memory.
I'm going to close this as the answer at this time is the component model, but if you have follow-up questions feel free to post them here.
HillOfTong commented on issue #10848:
Thanks!
Last updated: Dec 06 2025 at 06:05 UTC