Stream: wasmtime

Topic: Caller lifetime tips?


view this post on Zulip Albert Cervin (May 19 2022 at 10:20):

Hi, when using Caller to get a reference to the data stored, I often run into lifetime problems. I will have something that refers back to the data stored in the Store and then I want to for example call a callback. The problem then is that the Caller is tied to the call to caller.data_mut() (or similar) and cannot be used to call wasm functions. Any tips on dealing with that? Except cloning the data out of course, which works.

view this post on Zulip Alex Crichton (May 19 2022 at 14:02):

When you say you want to call a callback is that a wasm callback or something like a host callback? It's a known issue that when you borrow the T in a Caller<'_, T> then you can't access any other data in the Store<T> as a disjoint borrow, which you should theoretically be able to do. If you want to call wasm, though, that's an intentional limitation that you can't borrow T over a wasm call.

view this post on Zulip Albert Cervin (Jul 02 2022 at 17:37):

Thanks for the info! Yeah, borrowing T over a wasm call makes sense that you can not do. It was more the former case, being able to call methods on the store while T is borrowed.


Last updated: Oct 23 2024 at 20:03 UTC