Stream: wasmtime

Topic: typed result from a component


view this post on Zulip Ludea (Aug 22 2025 at 16:33):

Hi, I do

    let mut store = Store::new(&engine, state);

    let component = Component::from_file(&engine, "component.wasm")?;
    let instance = linker.instantiate_async(&mut store, &component).await?;
    let mut result = [];
    if let Some(func) = instance.get_func(&mut store, function) {
      func.call_async(&mut store, &[], &mut result).await?;
      println!("result : {:?}", result);
    } else {
      println!("No func")
    }

But I getExpected (1) result, go (0)
My component is https://github.com/bytecodealliance/wasmtime/blob/main/examples/component/wasm/guest.rs.
So the returned value is a f32.
I miss something?

A lightweight WebAssembly runtime that is fast, secure, and standards-compliant - bytecodealliance/wasmtime

view this post on Zulip Alex Crichton (Aug 22 2025 at 16:38):

you need to pass in a 1-length result array, so you'd have to fill in a dummy result such as let mut result = [Val::U8(0)]; so that would get filled in

view this post on Zulip Alex Crichton (Aug 22 2025 at 16:38):

You can find more documentation for call here


Last updated: Dec 06 2025 at 06:05 UTC