bytecodealliance / bytecodealliance/wasmtime

Component: Unclear how to access exported resource returned by guest

Open
#9,946 13 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
18.6k
Forks
1.8k
Avg merge
1d 19h
Merged PRs (30d)
121

Description

The [exported resources example](https://docs.wasmtime.dev/api/wasmtime/component/bindgen_examples/_6_exported_resources/index.html) shows how to create a guest resource. Unfortunately it doesn't show how to actually send that resource to an exported client function.

But, to this issue, it doesn't show how to access a resource returned by a call to the guest.

The guest returns `ResourceAny`, and the documentation does make it clear that this is expected. However, now what?

It cannot be converted to a `Resource`, because `try_into_resource` only works on host resources. (That is also not clear in the documentation, I had to delve into the source code to figure that out.)

Also, it's also unclear to me if I must call `resource_drop` on the value returned by the guest. Or is that necessary just for host resources?

The documentation could be more specific, and the example is not especially useful. In any case, I do not know how to proceed.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.