Hey, In wasmtime what's the best/most idiomatic way of copying a Vec<u8>
from the host memory to a wasmtime instance across the FFI boundary? I was reading an article that said you want to have the instance provide a *const u8
and have an exported alloc method and have the host side call that alloc method on the pointer and then fill it with the data. Is that the recommended way?
It's the only way I found when I looked for one, I can link you to some of my code if it can help
@Léo Gaspard I certainly wouldn't mind looking at it, thanks!
Hmm so the code is all in proc macros (I defined these to seamlessly serialize/deserialize in/out of wasm via serde-bincode) so it's a bit intricated, but the file is https://github.com/Ekleog/kannader/blob/master/kannader-config-macros/src/lib.rs ; the implement_guest macro defines the (de)alloc functions, and make__ macros have the (de)serialization based on that :)
Feel free to ask if there's any way I could help by explaining stuff! :)
Last updated: Dec 23 2024 at 12:05 UTC