ether 0.1.4

Library for parsing and manipulating network data, packet captures.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

use num::NumCast;

#[derive(Debug)]
pub struct Bitfield {
    value: u64,
}

impl Bitfield {
    pub fn new<N: NumCast>(value: N) -> Self {
        Bitfield { value: NumCast::from(value).unwrap() }
    }

    pub fn has(&self, offset: usize) -> bool {
        let mask = 1 << offset;
        self.value & mask == mask
    }
}