Stream: git-wasmtime

Topic: wasmtime / issue #12016 How to create an `Accessor` for a...


view this post on Zulip Wasmtime GitHub notifications bot (Nov 11 2025 at 12:04):

LeoDreamer2004 edited issue #12016:

I'm working on a WebAssembly interface with an async function defined in WIT:

package allay:plugin@1.0.0;

world plugin {
    export test: async func() -> string;
}

I'm using wasmtime::component::bindgen! to generate the bindings:

wasmtime::component::bindgen!({
    path: "wit",
    world: "plugin"
});

When I try to call the test function:

let instance = Plugin::instantiate(&mut store, &component, &linker)?;
instance.call_test().await?;

I encountered an issue. After expanding the macros, I found that the signature of call_test is:

pub async fn call_test<T, D>(&self, accessor: &Accessor) -> Result<String>;

Unlike Store, the Accessor type cannot be directly constructed by the user. What should I do in this situation? I would appreciate any guidance on how to resolve this.

Thanks in advance for your help!

view this post on Zulip Wasmtime GitHub notifications bot (Nov 12 2025 at 18:17):

primoly commented on issue #12016:

I believe you’ll need wasmtime::component::Instance::run_concurrent.

Here’s some demo code I think would work:

let config = wasmtime::Config::new();
let engine = wasmtime::Engine::new(&config)?;
let mut store = wasmtime::Store::new(&engine, ());
let component = wasmtime::component::Component::from_file(&engine, "plugin.wasm")?;
let linker = wasmtime::component::Linker::new(&engine);
let instance: wasmtime::component::Instance = linker.instantiate(&mut store, &component)?;
let plugin = Plugin::instantiate(&mut store, &component, &linker)?;
let test_result = instance
    .run_concurrent(&mut store, async |accessor| -> wasmtime::Result<String> {
        plugin.call_test(accessor).await
    })
    .await??;

view this post on Zulip Wasmtime GitHub notifications bot (Nov 12 2025 at 18:28):

LeoDreamer2004 commented on issue #12016:

It works! Many thanks

view this post on Zulip Wasmtime GitHub notifications bot (Nov 12 2025 at 18:28):

LeoDreamer2004 closed issue #12016:

I'm working on a WebAssembly interface with an async function defined in WIT:

package allay:plugin@1.0.0;

world plugin {
    export test: async func() -> string;
}

I'm using wasmtime::component::bindgen! to generate the bindings:

wasmtime::component::bindgen!({
    path: "wit",
    world: "plugin"
});

When I try to call the test function:

let instance = Plugin::instantiate(&mut store, &component, &linker)?;
instance.call_test().await?;

I encountered an issue. After expanding the macros, I found that the signature of call_test is:

pub async fn call_test<T, D>(&self, accessor: &Accessor) -> Result<String>;

Unlike Store, the Accessor type cannot be directly constructed by the user. What should I do in this situation? I would appreciate any guidance on how to resolve this.

Thanks in advance for your help!


Last updated: Dec 06 2025 at 07:03 UTC