Stream: wasmtime

Topic: ✔ how to get memory in wrapped host Func?


view this post on Zulip Braden McDorman (Feb 03 2022 at 05:18):

Hi, I have a Rust function I'm wrapping that needs access to the caller's memory. One of the arguments to the function is a guest pointer (not in the wiggle sense, but a raw u32). Right now I'm storing the Memory in the WasiCtx table to be looked up through the Caller I receive as a parameter. This seems like a hack, though. Is there a better way to go about this? Instantiation order (the instance is exporting the memory) means I can't pass it in through the closure.

view this post on Zulip Alex Crichton (Feb 03 2022 at 05:22):

I think the last example here might help https://docs.rs/wasmtime/latest/wasmtime/struct.Func.html#examples-2

view this post on Zulip Braden McDorman (Feb 03 2022 at 05:25):

Thanks @Alex Crichton . :weary: I don't know how I missed the get_export function on Caller.

view this post on Zulip Notification Bot (Feb 03 2022 at 05:26):

Braden McDorman has marked this topic as resolved.


Last updated: Nov 22 2024 at 16:03 UTC