binding/examples/flags.rs
Jason Travis Smith 2d6bed361e Rust 2018 fixes.
Removed the extern crate calls that were no longer required.
2019-01-21 21:08:26 -05:00

34 lines
706 B
Rust

use binding::c_flags;
c_flags!
{
/// A sample of flags useful for the EvDev library.
flags ReadFlags: u32
{
/// Process data in sync mode.
const SYNC = 0b000000000000000000000001,
/// Process data in normal mode.
const NORMAL = 0b000000000000000000000010,
/// Pretend the next event is a SYN_DROPPED and require
/// the caller to sync.
const FORCE_SYNC = 0b000000000000000000000100,
/// The fd is not in O_NONBLOCK and a read may block.
const BLOCKING = 0b000000000000000000001000
}
}
pub fn main()
{
let flag: ReadFlags;
flag = SYNC | NORMAL;
println!("Flag: {:#010b}", flag.get_bits());
println!("Flag: {}", flag);
}