Stream: general

Topic: default_func on module's instance


view this post on Zulip Hugues Morisset (Jun 29 2022 at 16:55):

Hello, I'm using wasmtime for the first time, the experience has been great doc is clear and the setup is quick.
I have a small question about Instance, Linker has a get_default method but Instance doesn't.
Given the following code snippet:

...
    let module = Module::from_file(&engine, wasm_file.as_str())?;

    linker.module_async(&mut store, "", &module).await?;
    let linked_module = linker.instantiate_pre(&mut store, &module)?;
    let instance = linked_module.instantiate_async(&mut store).await?;
    let default_func = linker.get_default(&mut store, "")?.typed::<(), (), _>(&store)?;
    let result = default_func.call_async(&mut store, ()).await?;
  1. I can remove both call on instantiate_pre and instantiate_async and everything will still run correctly, should I clone the store for each independent runs?
  2. instantiate_async()'s result here stay unused, it feels like it would make more sense if get_default() would be call on it rather than the linker, am I using all this in the wrong way?

view this post on Zulip Hugues Morisset (Jul 04 2022 at 08:39):

up


Last updated: Dec 23 2024 at 12:05 UTC