Stream: general

Topic: Best way to share types with additional impl and traits


view this post on Zulip Marek Vavrusa (Feb 21 2025 at 00:59):

Hi! What's the best way to share types between guest and host that have additional impls? Like for example I want to share enum and implement Display on the enum, I can do that on the guest side by generating bindings with wit-bindgen and adding impls on that, but I can't add the bindings to with: for wasmtine bindgen! macro since it doesn't generate host bindings, which makes sense but it's just enums. The best way I can think of is proc macros to generate new impls for generated types in both host and guest but it doesn't seem very nice.

view this post on Zulip Alex Crichton (Feb 21 2025 at 01:03):

you might be able to hack this up with a shared file that's include!'d on one half and used as a normal module on the other, but beyond that I'm not coming up with anything myself

view this post on Zulip Marek Vavrusa (Feb 21 2025 at 01:07):

ah yes that would work as well, I guess might be more readable than proc macros, thanks!


Last updated: Feb 28 2025 at 03:10 UTC