1use core::fmt;
4
5#[derive(Debug)]
7pub struct InvalidLength;
8
9impl fmt::Display for InvalidLength {
10 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
11 f.write_str("invalid length")
12 }
13}
14
15impl core::error::Error for InvalidLength {}
16
17#[derive(Debug)]
19pub struct OutOfRange;
20
21impl fmt::Display for OutOfRange {
22 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
23 f.write_str("out of range")
24 }
25}
26
27impl core::error::Error for OutOfRange {}
28
29#[derive(Debug)]
31pub enum ParseChildIndexError {
32 ParseInt(core::num::ParseIntError),
34 IndexNotInRange(OutOfRange),
36}
37
38impl fmt::Display for ParseChildIndexError {
39 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
40 match self {
41 Self::ParseInt(_) => f.write_str("child index is not valid u32 integer"),
42 Self::IndexNotInRange(_) => f.write_str("child index is not in acceptable range"),
43 }
44 }
45}
46
47impl core::error::Error for ParseChildIndexError {
48 fn source(&self) -> Option<&(dyn core::error::Error + 'static)> {
49 match self {
50 ParseChildIndexError::ParseInt(e) => Some(e),
51 ParseChildIndexError::IndexNotInRange(e) => Some(e),
52 }
53 }
54}