-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Component: Unclear how to access exported resource returned by guest #9946
Comments
A resource is an opaque id. I think all the host can do with a guest resource is to pass it as argument when calling a guest function or to call the drop function of the resource. |
@bjorn3 , actually I figured it out and it is possible. The example code is the hint. Here's how it's done:
I wish the example actually showed this. Instead, the example doesn't have any exported functions in the interface, which doesn't seem to me to be a very common scenario. |
@tliron do you have a suggestion for what WIT you'd like to see in the example? it sounds like you figured things out otherwise, but I'd be happy to help update the example to be more useful to you. |
I mostly figured things out, but I'm sorry, I doubt that others would, too. Also, I'm still not sure if I have to manually
On that note, why does Again, going back to my suggestion 1, a full example of dealing with this would make these challenges easier to see. |
The exported resources example 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
, becausetry_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.
The text was updated successfully, but these errors were encountered: