You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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, 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.
The text was updated successfully, but these errors were encountered:
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:
First, create the dispatcher. From the example: let logger = guest.logger();
Then, do not call call_constructor. We already have the ResourceAny! In fact, call_constructor returns a ResourceAny, too.
So now just call the resource functions via the dispatcher on the ResourceAny that you got from the guest, e.g. logger.call_log(&mut store, my_returned_value, Level::Debug, "hello!")?;
I'm pretty sure you need to drop_resource, too, when you're done. Well, at least it doesn't return an error when I call it.
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.
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: