Hi
I'm trying to crate a wrapper around an existing interface which takes a resource (which doesn't declare a constructor) as an input. Is there a way to create a component which takes different inputs, creates and instance of that resource and calls the existing interface?
Specifically I'm stuck on the fact that the generated bindings don't seem to include any way to instantiate the resource.
To be usable, the inner interface either needs a constructor or some other function that returns a handle.
In this case I want to wrap the wasi:http/incoming-handler
, so I cannot modify it in any way.
So there is not workaround to make this work and that interface just cannot be used from plain wasm?
Ah, that's a good question. I don't know the answer.
I think this is an artifact of the asymmetric API of wasi:http@0.2.0
, where the underlying assumption is that the only party who should be creating instances of incoming-request
is the one who is exporting that resource -- normally the host, but possibly a component.
What you're trying to do is trivial in the 0.3.0-draft since there's only one request
resource, which has a constructor that any component can call. And in general WASIp3 will make virtualizing interfaces which involve I/O practical, which isn't really the case for WASIp2, unfortunately. I've tried several times to virtualize wasi:http@0.2.x
and failed, which is one of the reasons I'm so keen to get WASIp3 released.
Last updated: Jan 24 2025 at 00:11 UTC