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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
use 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
}
}