Stream: general

Topic: Copying Vec from host to module


view this post on Zulip XAMPPRocky (Jan 14 2021 at 08:33):

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?

view this post on Zulip Léo Gaspard (Jan 14 2021 at 08:57):

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

view this post on Zulip XAMPPRocky (Jan 14 2021 at 09:16):

@Léo Gaspard I certainly wouldn't mind looking at it, thanks!

view this post on Zulip Léo Gaspard (Jan 14 2021 at 10:26):

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 :)

A highly configurable SMTP server written in Rust. Contribute to Ekleog/kannader development by creating an account on GitHub.

view this post on Zulip Léo Gaspard (Jan 14 2021 at 10:27):

Feel free to ask if there's any way I could help by explaining stuff! :)


Last updated: Dec 23 2024 at 12:05 UTC