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)
}
}