When having multiple wit_bindgen::generate!
macro calls, (e.g. in two dependencies) they each create their own types.
So if they both use a resource type, the resource type from each generate!
is different, making it impossible to reuse code between them.
I.e. you can't take a wasi:http/request-options
from one, and pass it to the other, even though they're really the same underlying thing.
Is there any way to work around this? Perhaps I'm missing something?
yep, this is what with
clauses are for: https://github.com/bytecodealliance/wasmtime/blob/main/crates/wasi-http/src/lib.rs#L60
Does wit-bindgen support the same thing? I'm having this issue on the guest side, not the runtime's side.
ah, sorry. i think that feature may be missing in guest wit-bindgen
i recall this comes up pretty frequently
maybe someone did add it in the last month, ive been offline
To make it a bit more concrete, this is relevant for wasi-webgpu where we expect most rust users to use the wgpu crate instead of relying on wasi-webgpu directly.
So I'm working on a wasi-backend for wgpu, but we also expect the users to be able to connect the gpu device to a canvas/window. And now the wgpu generated types are incompatible with the types generated by the crate itself.
:face_palm: If only I'd read the docs...
It specifically addresses this case...
https://docs.rs/wit-bindgen/0.24.0/wit_bindgen/macro.generate.html#options-to-generate
Last updated: Nov 22 2024 at 16:03 UTC