bytecodealliance/wit-bindgen

rust: How to export all structs

Closed this issue · 3 comments

oovm commented

How to make wit_bindgen::generate! generate all types in world export <<interface>>?

Dead code elimination is performed by default.

If a record or variant is not an input or return value of any function, such a type will not be generated as rust struct and enum.

Currently there's no option to do this, but if you'd like I think it'd be reasonable to add an option. A PR for this would be most welcome!

oovm commented

I can try to submit a PR, but I don’t know what should be changed

  1. I am going to add allow_unused: bool here

  1. This seems to be the entrance to the backend, but unused has been deleted before.

fn print_typedef_record(&mut self, id: TypeId, record: &Record, docs: &Docs) {

I believe the main thing you'll want to change is this line where you'll want to consult self.gen.opts.<your-option-here>. That'd then be plumbed through the macro in the enum Opt you found as well.