rusty_ffmpeg icon indicating copy to clipboard operation
rusty_ffmpeg copied to clipboard

Better enum type name

Open ldm0 opened this issue 3 years ago • 1 comments

Current we got enum like this:

pub const AVMediaType_AVMEDIA_TYPE_NB: AVMediaType = 5;

Which is not good to use. And the rust-bindgen provides us several options: https://docs.rs/bindgen/0.55.1/bindgen/struct.Builder.html

However they all not suitable for out situation. I want the generated enum can be directly used(rustified_enum creates const in impl, which cannot be used just like the bitflags crate does), and is able to do calculation(which makes newtype_enum not suitable, it construct a new_type containing a integer), and extendable(some consts cnanot be directly generated with bindgen, which need to be add by hand, but generate const value in a specific module makes adding them not possible), The bitfield_enum is better but each enum only occupies a bit, which makes the maximum number of each enum is limited.

The last option is trimming the prefix of each enum, which is suitable since FFmpeg's enum name never overlaps. So it's blocked on https://github.com/rust-lang/rust-bindgen/issues/777

ldm0 avatar Oct 22 '20 17:10 ldm0

The problem is the callback receives unprefixed identifier, like the AVMEDIA_TYPE_VIDEO for AVMediaType_AVMEDIA_TYPE_VIDEO, which makes it impossible to trim out the AVMediaType. So depending on the https://github.com/rust-lang/rust-bindgen/issues/777 is impossible.

ldm0 avatar Nov 06 '20 16:11 ldm0