bit_buf/error.rs
1use core::fmt::{self, Display};
2
3/// Error from checked operations
4#[derive(Debug)]
5pub enum Error {
6 /// An operation failed due to storage not containing enough data
7 OutOfBounds,
8 /// The requested bit count exceeds the maximum width for the operating type
9 InvalidBitCount,
10}
11
12impl Display for Error {
13 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
14 use Error::*;
15 match self {
16 OutOfBounds => write!(f, "BitBuf: operation out of bounds"),
17 InvalidBitCount => write!(f, "BitBuf: requested bit count exceeds type width"),
18 }
19 }
20}
21
22impl core::error::Error for Error {}