Skip to content

Commit

Permalink
Retain instead of truncate unknown flags when converting to bitflags (
Browse files Browse the repository at this point in the history
#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.
  • Loading branch information
MarijnS95 authored Nov 10, 2023
1 parent 83df458 commit 0394443
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ impl Default for Flags {

impl From<u32> for Flags {
fn from(flags: u32) -> Self {
Self::from_bits_truncate(flags)
Self::from_bits_retain(flags)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/capability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ bitflags::bitflags! {

impl From<u32> for Flags {
fn from(flags: u32) -> Self {
Self::from_bits_truncate(flags)
Self::from_bits_retain(flags)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ bitflags::bitflags! {

impl From<u32> for Flags {
fn from(flags: u32) -> Self {
Self::from_bits_truncate(flags)
Self::from_bits_retain(flags)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/format/description.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ bitflags::bitflags! {

impl From<u32> for Flags {
fn from(flags: u32) -> Self {
Self::from_bits_truncate(flags)
Self::from_bits_retain(flags)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/format/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ bitflags::bitflags! {

impl From<u32> for Flags {
fn from(flags: u32) -> Self {
Self::from_bits_truncate(flags)
Self::from_bits_retain(flags)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ bitflags::bitflags! {

impl From<u32> for Capabilities {
fn from(caps: u32) -> Self {
Self::from_bits_truncate(caps)
Self::from_bits_retain(caps)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/video/capture/parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ bitflags::bitflags! {

impl From<u32> for Modes {
fn from(caps: u32) -> Self {
Self::from_bits_truncate(caps)
Self::from_bits_retain(caps)
}
}

Expand Down

0 comments on commit 0394443

Please sign in to comment.