It\'s possible to declare flags in Rust - similar to how it would be done in C.
pub const FOO: u32 = (1 << 0);
pub const BAR: u32 = (1 << 1);
let fl
You could (I don't know if it is in any way idiomatic) just use Rust's enums :
pub enum MyFlags {
Meaning1,
Meaning2,
Meaning3,
...,
MeaningX
}
This way you have a clear meaning for your flags. Once done, you can write some helper functions around this enum for Rust-to-C conversion.
fn to_u32(flag: &MyFlags) -> u32 {
match flag {
&MyFlags::Meaning1 => return (1 << 0),
&MyFlags::Meaning2 => return (1 << 1),
&MyFlags::Meaning3 => return (1 << 2),
&MyFlags::MeaningX => return (1 << 3),
}
}
fn to_bitflags_flags(flags: &Vec) -> u32 {
let mut bitflags = 0u32;
for flag in flags {
bitflags |= to_u32(flag);
}
return bitflags;
}