diff --git a/Cargo.toml b/Cargo.toml index 59bc8dfa..06311c6c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,7 @@ keywords = ["ffmpeg", "multimedia", "video", "audio"] categories = ["multimedia"] [features] -default = ["codec", "device", "filter", "format", "software-resampling", "software-scaling"] +default = ["codec", "device", "filter", "format", "software-resampling", "software-scaling", "non-exhaustive-enums"] # ffmpeg are obsolete features kept for backward compatibility purposes and # don't do anything anymore (equivalents are automatically specified through @@ -29,6 +29,9 @@ ffmpeg4 = [] static = ["ffmpeg-sys-next/static"] build = ["static", "ffmpeg-sys-next/build"] +# mark enums in generated bindings as #[non_exhaustive] +non-exhaustive-enums = ["ffmpeg-sys-next/non-exhaustive-enums"] + # licensing build-license-gpl = ["ffmpeg-sys-next/build-license-gpl"] build-license-nonfree = ["ffmpeg-sys-next/build-license-nonfree"] diff --git a/src/codec/audio_service.rs b/src/codec/audio_service.rs index 37486ce4..91837a3a 100644 --- a/src/codec/audio_service.rs +++ b/src/codec/audio_service.rs @@ -27,6 +27,9 @@ impl From for AudioService { AV_AUDIO_SERVICE_TYPE_VOICE_OVER => AudioService::VoiceOver, AV_AUDIO_SERVICE_TYPE_KARAOKE => AudioService::Karaoke, AV_AUDIO_SERVICE_TYPE_NB => AudioService::Main, + + #[cfg(feature = "non-exhaustive-enums")] + _ => unimplemented!(), } } } diff --git a/src/codec/discard.rs b/src/codec/discard.rs index 156712cb..b540ef84 100644 --- a/src/codec/discard.rs +++ b/src/codec/discard.rs @@ -22,6 +22,9 @@ impl From for Discard { AVDISCARD_NONINTRA => Discard::NonIntra, AVDISCARD_NONKEY => Discard::NonKey, AVDISCARD_ALL => Discard::All, + + #[cfg(feature = "non-exhaustive-enums")] + _ => unimplemented!(), } } } diff --git a/src/codec/field_order.rs b/src/codec/field_order.rs index 67a5b7e2..4fba0426 100644 --- a/src/codec/field_order.rs +++ b/src/codec/field_order.rs @@ -20,6 +20,9 @@ impl From for FieldOrder { AV_FIELD_BB => FieldOrder::BB, AV_FIELD_TB => FieldOrder::TB, AV_FIELD_BT => FieldOrder::BT, + + #[cfg(feature = "non-exhaustive-enums")] + _ => unimplemented!(), } } } diff --git a/src/codec/id.rs b/src/codec/id.rs index aed11b53..931344f1 100644 --- a/src/codec/id.rs +++ b/src/codec/id.rs @@ -1295,6 +1295,9 @@ impl From for Id { AV_CODEC_ID_VNULL => Id::VNULL, #[cfg(feature = "ffmpeg_6_0")] AV_CODEC_ID_ANULL => Id::ANULL, + + #[cfg(feature = "non-exhaustive-enums")] + _ => unimplemented!(), } } } diff --git a/src/codec/packet/side_data.rs b/src/codec/packet/side_data.rs index 5c2f73d0..3a8cc53c 100644 --- a/src/codec/packet/side_data.rs +++ b/src/codec/packet/side_data.rs @@ -106,6 +106,9 @@ impl From for Type { #[cfg(feature = "ffmpeg_5_0")] AV_PKT_DATA_DYNAMIC_HDR10_PLUS => Type::DYNAMIC_HDR10_PLUS, + + #[cfg(feature = "non-exhaustive-enums")] + _ => unimplemented!(), } } } diff --git a/src/codec/subtitle/mod.rs b/src/codec/subtitle/mod.rs index 8e2e2ecd..607d8580 100644 --- a/src/codec/subtitle/mod.rs +++ b/src/codec/subtitle/mod.rs @@ -29,6 +29,9 @@ impl From for Type { SUBTITLE_BITMAP => Type::Bitmap, SUBTITLE_TEXT => Type::Text, SUBTITLE_ASS => Type::Ass, + + #[cfg(feature = "non-exhaustive-enums")] + _ => unimplemented!(), } } } diff --git a/src/software/resampling/dither.rs b/src/software/resampling/dither.rs index fc991059..4dd9586b 100644 --- a/src/software/resampling/dither.rs +++ b/src/software/resampling/dither.rs @@ -34,6 +34,9 @@ impl From for Dither { SWR_DITHER_NS_LOW_SHIBATA => Dither::NoiseShapingLowShibata, SWR_DITHER_NS_HIGH_SHIBATA => Dither::NoiseShapingHighShibata, SWR_DITHER_NB => Dither::None, + + #[cfg(feature = "non-exhaustive-enums")] + _ => unimplemented!(), } } } diff --git a/src/software/resampling/engine.rs b/src/software/resampling/engine.rs index cc2681a1..b14a8a9f 100644 --- a/src/software/resampling/engine.rs +++ b/src/software/resampling/engine.rs @@ -13,6 +13,9 @@ impl From for Engine { SWR_ENGINE_SWR => Engine::Software, SWR_ENGINE_SOXR => Engine::SoundExchange, SWR_ENGINE_NB => Engine::Software, + + #[cfg(feature = "non-exhaustive-enums")] + _ => unimplemented!(), } } } diff --git a/src/software/resampling/filter.rs b/src/software/resampling/filter.rs index 3d5b9cc1..d85c4e2e 100644 --- a/src/software/resampling/filter.rs +++ b/src/software/resampling/filter.rs @@ -14,6 +14,9 @@ impl From for Filter { SWR_FILTER_TYPE_CUBIC => Filter::Cubic, SWR_FILTER_TYPE_BLACKMAN_NUTTALL => Filter::BlackmanNuttall, SWR_FILTER_TYPE_KAISER => Filter::Kaiser, + + #[cfg(feature = "non-exhaustive-enums")] + _ => unimplemented!(), } } } diff --git a/src/util/chroma/location.rs b/src/util/chroma/location.rs index 28f15bb2..25147922 100644 --- a/src/util/chroma/location.rs +++ b/src/util/chroma/location.rs @@ -23,6 +23,9 @@ impl From for Location { AVCHROMA_LOC_BOTTOMLEFT => Location::BottomLeft, AVCHROMA_LOC_BOTTOM => Location::Bottom, AVCHROMA_LOC_NB => Location::Unspecified, + + #[cfg(feature = "non-exhaustive-enums")] + _ => unimplemented!(), } } } diff --git a/src/util/color/primaries.rs b/src/util/color/primaries.rs index 0ae557fc..323a0402 100644 --- a/src/util/color/primaries.rs +++ b/src/util/color/primaries.rs @@ -66,6 +66,9 @@ impl From for Primaries { AVCOL_PRI_JEDEC_P22 => Primaries::JEDEC_P22, #[cfg(feature = "ffmpeg_4_3")] AVCOL_PRI_EBU3213 => Primaries::EBU3213, + + #[cfg(feature = "non-exhaustive-enums")] + _ => unimplemented!(), } } } diff --git a/src/util/color/range.rs b/src/util/color/range.rs index e1ad3958..476886ad 100644 --- a/src/util/color/range.rs +++ b/src/util/color/range.rs @@ -31,6 +31,9 @@ impl From for Range { AVCOL_RANGE_MPEG => Range::MPEG, AVCOL_RANGE_JPEG => Range::JPEG, AVCOL_RANGE_NB => Range::Unspecified, + + #[cfg(feature = "non-exhaustive-enums")] + _ => unimplemented!(), } } } diff --git a/src/util/color/space.rs b/src/util/color/space.rs index 82dde415..c38e8e7f 100644 --- a/src/util/color/space.rs +++ b/src/util/color/space.rs @@ -59,6 +59,9 @@ impl From for Space { AVCOL_SPC_CHROMA_DERIVED_NCL => Space::ChromaDerivedNCL, AVCOL_SPC_CHROMA_DERIVED_CL => Space::ChromaDerivedCL, AVCOL_SPC_ICTCP => Space::ICTCP, + + #[cfg(feature = "non-exhaustive-enums")] + _ => unimplemented!(), } } } diff --git a/src/util/color/transfer_characteristic.rs b/src/util/color/transfer_characteristic.rs index e35aad0e..965e6285 100644 --- a/src/util/color/transfer_characteristic.rs +++ b/src/util/color/transfer_characteristic.rs @@ -63,6 +63,9 @@ impl From for TransferCharacteristic { AVCOL_TRC_SMPTE2084 => TransferCharacteristic::SMPTE2084, AVCOL_TRC_SMPTE428 => TransferCharacteristic::SMPTE428, AVCOL_TRC_ARIB_STD_B67 => TransferCharacteristic::ARIB_STD_B67, + + #[cfg(feature = "non-exhaustive-enums")] + _ => unimplemented!(), } } } diff --git a/src/util/format/pixel.rs b/src/util/format/pixel.rs index 93f94e6c..0d069bbb 100644 --- a/src/util/format/pixel.rs +++ b/src/util/format/pixel.rs @@ -808,10 +808,13 @@ impl From for Pixel { AV_PIX_FMT_RPI4_8 => Pixel::RPI4_8, #[cfg(feature = "rpi")] AV_PIX_FMT_RPI4_10 => Pixel::RPI4_10, + #[cfg(feature = "non-exhaustive-enums")] + _ => unimplemented!(), } } } +#[allow(unreachable_patterns)] impl From for AVPixelFormat { #[inline] fn from(value: Pixel) -> AVPixelFormat { @@ -1221,6 +1224,8 @@ impl From for AVPixelFormat { Pixel::RPI4_8 => AV_PIX_FMT_RPI4_8, #[cfg(feature = "rpi")] Pixel::RPI4_10 => AV_PIX_FMT_RPI4_10, + #[cfg(feature = "non-exhaustive-enums")] + _ => unimplemented!("Not all current or future pixel formats are supported yet"), } } } diff --git a/src/util/format/sample.rs b/src/util/format/sample.rs index 7f1b14dd..5f8f4f56 100644 --- a/src/util/format/sample.rs +++ b/src/util/format/sample.rs @@ -86,6 +86,9 @@ impl From for Sample { AV_SAMPLE_FMT_DBLP => Sample::F64(Type::Planar), AV_SAMPLE_FMT_NB => Sample::None, + + #[cfg(feature = "non-exhaustive-enums")] + _ => unimplemented!(), } } } diff --git a/src/util/frame/side_data.rs b/src/util/frame/side_data.rs index dd5e62f0..c80cf23b 100644 --- a/src/util/frame/side_data.rs +++ b/src/util/frame/side_data.rs @@ -126,6 +126,8 @@ impl From for Type { #[cfg(feature = "ffmpeg_6_0")] AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT => Type::AMBIENT_VIEWING_ENVIRONMENT, + #[cfg(feature = "non-exhaustive-enums")] + _ => unimplemented!(), } } } diff --git a/src/util/mathematics/rounding.rs b/src/util/mathematics/rounding.rs index b3d279d4..abe2800f 100644 --- a/src/util/mathematics/rounding.rs +++ b/src/util/mathematics/rounding.rs @@ -21,6 +21,9 @@ impl From for Rounding { AV_ROUND_UP => Rounding::Up, AV_ROUND_NEAR_INF => Rounding::NearInfinity, AV_ROUND_PASS_MINMAX => Rounding::PassMinMax, + + #[cfg(feature = "non-exhaustive-enums")] + _ => unimplemented!(), } } } diff --git a/src/util/media.rs b/src/util/media.rs index 531f624f..ff9ca292 100644 --- a/src/util/media.rs +++ b/src/util/media.rs @@ -22,6 +22,9 @@ impl From for Type { AVMEDIA_TYPE_SUBTITLE => Type::Subtitle, AVMEDIA_TYPE_ATTACHMENT => Type::Attachment, AVMEDIA_TYPE_NB => Type::Unknown, + + #[cfg(feature = "non-exhaustive-enums")] + _ => unimplemented!(), } } } diff --git a/src/util/option/mod.rs b/src/util/option/mod.rs index e340d980..a858630a 100644 --- a/src/util/option/mod.rs +++ b/src/util/option/mod.rs @@ -53,6 +53,9 @@ impl From for Type { AV_OPT_TYPE_CHANNEL_LAYOUT => Type::ChannelLayout, #[cfg(feature = "ffmpeg_5_1")] AV_OPT_TYPE_CHLAYOUT => Type::ChannelLayout, + + #[cfg(feature = "non-exhaustive-enums")] + _ => unimplemented!(), } } } diff --git a/src/util/picture.rs b/src/util/picture.rs index c89a918b..de2e5335 100644 --- a/src/util/picture.rs +++ b/src/util/picture.rs @@ -25,6 +25,9 @@ impl From for Type { AV_PICTURE_TYPE_SI => Type::SI, AV_PICTURE_TYPE_SP => Type::SP, AV_PICTURE_TYPE_BI => Type::BI, + + #[cfg(feature = "non-exhaustive-enums")] + _ => unimplemented!(), } } }