pub trait OpenCVBitfieldEnum:
Sized
+ Copy
+ 'static {
const ALL_FLAGS: &'static [Self];
// Required methods
unsafe fn from_i32_unchecked(value: i32) -> Self;
fn to_i32(self) -> i32;
// Provided methods
fn try_from_i32(value: i32) -> Result<Self> { ... }
fn is_set(self, flag: Self) -> bool { ... }
fn set(&mut self, flag: Self) { ... }
fn clear(&mut self, flag: Self) { ... }
fn toggle(&mut self, flag: Self) { ... }
fn with(self, flags: Self) -> Self { ... }
fn without(self, flags: Self) -> Self { ... }
}Expand description
Common trait for all enums that represent flags, e.g. can be combined using bitwise operations
Required Associated Constants§
Required Methods§
Sourceunsafe fn from_i32_unchecked(value: i32) -> Self
unsafe fn from_i32_unchecked(value: i32) -> Self
Construct the enum from an i32 value without checking its validity
§Safety
The caller must ensure that value is a valid combination of flags defined in Self::ALL_FLAGS.
Provided Methods§
Sourcefn try_from_i32(value: i32) -> Result<Self>
fn try_from_i32(value: i32) -> Result<Self>
Construct the enum from an i32 value, returning an error if any of the set bits do not have associated flags
Sourcefn set(&mut self, flag: Self)
fn set(&mut self, flag: Self)
Set the specified flag or flags
If the specified flag has 0 value, then it replaces the current value completely as it’s the only way to “set”
0-value flag.
Sourcefn clear(&mut self, flag: Self)
fn clear(&mut self, flag: Self)
Clear the specified flag or flags
If the specified flag has 0 value, then it does nothing.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.