Convert C/C++ typedef or struct or types into Rust-native

Hi,

I have a whole bunch of C/C++ header files that I want to convert to native data structures in Rust.
The headers lay out the structure of different data records.
So apart from what's in the headers, there will be no unknown variants.
The headers also contain union definitions which I'm sure is better replaced by Rust enum type.

Example:

enum Record {
    RecType1 { ..}
    RecType2 { ..}
}

I can use bindgen as a start but that'll insist on keeping certain aspects of the C/C++ definitions.
Apart from doing this by hand for hundreds of record types, is there any other crate that can get me close enough?

Cheers.

Do you just want a Rust type that could serve the same purpose, or do you actually need to use it in FFI? Rust enums are not FFI compatible with C tagged unions.

Hi, thanks for replying.
Just need the Rust types to serve the same purpose, no FFI necessary.

@alice thoughts?

Actually, they can have #[repr(...)] and they'll do. Type layout - The Rust Reference (rust-lang.org).

This looks like a text processing problem.
Maybe an awk script would be easier than doing it by hand?