modular_bitfield/
error.rsuse core::fmt::Debug;
#[derive(Debug, PartialEq, Eq)]
pub struct OutOfBounds;
impl core::fmt::Display for OutOfBounds {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
write!(f, "encountered an out of bounds value")
}
}
#[derive(Debug, PartialEq, Eq)]
pub struct InvalidBitPattern<Bytes> {
pub invalid_bytes: Bytes,
}
impl<Bytes> core::fmt::Display for InvalidBitPattern<Bytes>
where
Bytes: Debug,
{
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
write!(
f,
"encountered an invalid bit pattern: {:X?}",
self.invalid_bytes
)
}
}
impl<Bytes> InvalidBitPattern<Bytes> {
#[inline]
pub fn new(invalid_bytes: Bytes) -> Self {
Self { invalid_bytes }
}
#[inline]
pub fn invalid_bytes(self) -> Bytes {
self.invalid_bytes
}
}