1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
pub type Result<T> = std::result::Result<T, BitReaderError>;
#[derive(Fail, Debug)]
pub enum BitReaderError {
#[fail(display = "BitReader: Requested {} bits with only ({}-{})/{} bits left (position {})", requested, length, position , length, position)]
NotEnoughData {
position: usize,
length: usize,
requested: usize,
},
#[fail(display = "BitReader: Requested {} bits while the type can only hold {} (position {})", requested, allowed, position)]
TooManyBitsForType {
position: usize,
requested: u8,
allowed: u8,
},
#[fail(display = "io::Error : {}", _0)]
Io(#[cause] std::io::Error)
}
impl From<std::io::Error> for BitReaderError
{
fn from(error : std::io::Error) -> BitReaderError
{
BitReaderError::Io(error)
}
}