Skip to content

wasmtime::component::bindgen: How to specify a resource in "imports:"? #13768

Description

@tliron

In the documentation here there are examples of imported interfaces, but not of resources in the interfaces.

Specificaly I want to mark only the resource as async. I've tried various notations to no avail.

Given this world:

package floria:plugins;

world dispatch-plugin {
    import floria;
}

interface floria {
    resource session {
        constructor();
        get-entity: func(id: string) -> result<string, string>;
    }

Here are my bindings:

wasmtime::component::bindgen!({
    path: "assets/wit/floria-plugins.wit",
    imports: {
        // "floria:plugins/floria.session": async | trappable,
        default: trappable,
    }
});

The commented-out line is one of my attempts. :) However, I get errors such as this:

unused `imports` rules found: ["\"floria:plugins/floria.session\": FunctionFlags(ASYNC | TRAPPABLE)"]

What is the correct notation for referring to resources in imports? Is it even possible?

Note that I truncated the WIT file here. In fact I have many more imports, which I do not want to be async.

Metadata

Metadata

Assignees

No one assigned

    Labels

    wasmtime:docsIssues related to Wasmtime's documentation

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions