From 0394443c51571181f7aa77d5d6e015b27914b730 Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Sat, 11 Nov 2023 00:20:12 +0100 Subject: [PATCH] Retain instead of truncate unknown flags when converting to `bitflags` (#80) `bitflags` intrinsically supports holding unknown flag values, and pretty-printing a non-zero hex code if there are any. This should make our conversion functions lossless and allow us/users to more easily spot new, unsupported constants. --- src/buffer.rs | 2 +- src/capability.rs | 2 +- src/control.rs | 2 +- src/format/description.rs | 2 +- src/format/mod.rs | 2 +- src/parameters.rs | 2 +- src/video/capture/parameters.rs | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/buffer.rs b/src/buffer.rs index 080597c..59a4c3e 100644 --- a/src/buffer.rs +++ b/src/buffer.rs @@ -81,7 +81,7 @@ impl Default for Flags { impl From for Flags { fn from(flags: u32) -> Self { - Self::from_bits_truncate(flags) + Self::from_bits_retain(flags) } } diff --git a/src/capability.rs b/src/capability.rs index 55483ee..835e2e6 100644 --- a/src/capability.rs +++ b/src/capability.rs @@ -45,7 +45,7 @@ bitflags::bitflags! { impl From for Flags { fn from(flags: u32) -> Self { - Self::from_bits_truncate(flags) + Self::from_bits_retain(flags) } } diff --git a/src/control.rs b/src/control.rs index 4631558..db434af 100644 --- a/src/control.rs +++ b/src/control.rs @@ -84,7 +84,7 @@ bitflags::bitflags! { impl From for Flags { fn from(flags: u32) -> Self { - Self::from_bits_truncate(flags) + Self::from_bits_retain(flags) } } diff --git a/src/format/description.rs b/src/format/description.rs index 24434ac..e5f0039 100644 --- a/src/format/description.rs +++ b/src/format/description.rs @@ -15,7 +15,7 @@ bitflags::bitflags! { impl From for Flags { fn from(flags: u32) -> Self { - Self::from_bits_truncate(flags) + Self::from_bits_retain(flags) } } diff --git a/src/format/mod.rs b/src/format/mod.rs index 09f24fb..27d782d 100644 --- a/src/format/mod.rs +++ b/src/format/mod.rs @@ -29,7 +29,7 @@ bitflags::bitflags! { impl From for Flags { fn from(flags: u32) -> Self { - Self::from_bits_truncate(flags) + Self::from_bits_retain(flags) } } diff --git a/src/parameters.rs b/src/parameters.rs index f9d5331..a46b0c0 100644 --- a/src/parameters.rs +++ b/src/parameters.rs @@ -9,7 +9,7 @@ bitflags::bitflags! { impl From for Capabilities { fn from(caps: u32) -> Self { - Self::from_bits_truncate(caps) + Self::from_bits_retain(caps) } } diff --git a/src/video/capture/parameters.rs b/src/video/capture/parameters.rs index 25981ef..1a3a89f 100644 --- a/src/video/capture/parameters.rs +++ b/src/video/capture/parameters.rs @@ -13,7 +13,7 @@ bitflags::bitflags! { impl From for Modes { fn from(caps: u32) -> Self { - Self::from_bits_truncate(caps) + Self::from_bits_retain(caps) } }