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
use std::{error, fmt};
#[derive(Debug)]
pub(crate) struct ReadExactError {
pub(crate) remaining: u64,
pub(crate) buf_len: usize,
}
impl error::Error for ReadExactError {
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
None
}
}
impl fmt::Display for ReadExactError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"Cursor had {} bytes remaining but buffer was {} bytes long",
self.remaining, self.buf_len
)
}
}