Not sure if this is the right stream, but what is the right way to implement a resource? I'm trying to implement a connector component that provides a connection resource. The goal is to abstract the different kinds of connections via a resource.
Now, this connection resource is getting generated as a zero variant enum (Connection) by wit-bindgen. But I can't push that to the resource table, so I'm pushing my real object (odbc_api::Connection) into the table, getting the rep, and returning an ad hoc Connection resource with that rep. And when I get the method call, I'm using the rep value to look up the odbc_api::Connection in the table.
Is this the right way? It seems a bit hacky and I was wondering if there is a better/more direct way.
In Wasmtime you'll probably want to use with: { ... }
to customize the resource type to your own type so you can use the methods of ResourceTable
natively
Thanks @Alex Crichton, yeah I was able to map it to my own enum with the connection variants I care about.
Last updated: Nov 22 2024 at 17:03 UTC