Stream: C#/.net-collaboration

Topic: wit-bindgen interface directions and generated types


view this post on Zulip Scott Waye (Aug 29 2025 at 19:31):

I am attempting to tidy the generation of the import and export methods and types so the live in symmetrical places, under the interface definitions, rather than the import side being there, and the export side in the interop class. Some types like resources have drop methods so their implementation is different import v export. Then anything that can contain a resource, like a record, would also need its own type for import v export. Other types like enums can be shared between import and export. To implement this I'll need to know when generating the types what direction of interface they are used in, which presumably is not too hard. My question is does rust do something similar in terms of creating different types for the imports and exports?

view this post on Zulip Scott Waye (Aug 29 2025 at 19:32):

Or am I doing something that isn't that great an idea?

view this post on Zulip Joel Dice (Aug 29 2025 at 19:59):

Yes, the Rust generator generates different types for imported and exported versions of a given resource type and likewise for other types containing resources, and I imagine every generator needs to do that.

view this post on Zulip Scott Waye (Aug 29 2025 at 20:49):

Good to know, how does that work for aliases, how does the generator know if it needs to generate code for the alias, which presumably it doesn't do, if the alias is used in the same direction as the aliased type?


Last updated: Dec 06 2025 at 06:05 UTC