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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
use std::fmt::Display;

#[non_exhaustive]
#[derive(Debug, Clone, Copy)]
pub enum Error {
    Null,

    Not,

    Consume,

    Slice,

    String,

    End,

    Start,

    LockMutex,

    Option,

    FromStr,

    TryInto,

    SelectEq,

    SepCollect,

    Collect,

    Separate,

    RegexRepeat,

    NeuRepeatRange,

    NeuRepeat,

    NeuOneMore,

    NeuOne,

    NeuThen,

    OriginOutOfBound,

    Vec,

    PairVec,

    Utf8Error,

    FromLeBytes,

    FromBeBytes,

    Other,

    Uid(usize),
}

impl std::error::Error for Error {}

impl Display for Error {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            Error::Null => write!(f, "Error::Null"),
            Error::Not => write!(f, "In (`not`): got error when invoke regex"),
            Error::Consume => write!(f, "In (`consume`): need more data"),
            Error::Slice => write!(f, "In (`slice`): bytes not equal"),
            Error::String => write!(f, "In (`string`): string not equal"),
            Error::End => write!(f, "In (`end`): offset is not at the ending"),
            Error::Start => write!(f, "In (`start`): offset is not at the begining"),
            Error::LockMutex => write!(f, "Can not lock mutex for regex"),
            Error::Option => write!(f, "In (`Option`): unexcepted `None` value"),
            Error::FromStr => write!(f, "In (`FromStr`): got error in `from_str_radix`"),
            Error::TryInto => write!(f, "In (`MapTryInto`): got error in `TryInto::try_into`"),
            Error::SelectEq => write!(f, "In (`SelectEq`): tuple.0 and tuple.1 not equal"),
            Error::SepCollect => write!(f, "In (`SepCollect`): need more data"),
            Error::Collect => write!(f, "In (`Collect`): need more data"),
            Error::Separate => write!(f, "In (`Separate`): need more data"),
            Error::RegexRepeat => write!(f, "In (`RegexRepeat`): need more data"),
            Error::NeuRepeatRange => write!(f, "In (`NeuRepeatRange`): need more data"),
            Error::NeuRepeat => write!(f, "In (`NeuRepeat`): need more data"),
            Error::NeuOneMore => write!(f, "In (`NeuOneMore`): need more data"),
            Error::NeuOne => write!(f, "In (`NeuOne`): need more data"),
            Error::NeuThen => write!(f, "In (`NeuThen`): need more data"),
            Error::Vec => write!(f, "In (`Vec`): all match failed"),
            Error::PairVec => write!(f, "In (`Hash`): all match failed"),
            Error::OriginOutOfBound => write!(f, "Offset out of bound"),
            Error::Utf8Error => write!(f, "In (`FromUtf8`): catch `Utf8Error` or `FromUtf8Error`"),
            Error::FromLeBytes => write!(f, "In (`FromLeBytes`): need more bytes for given type"),
            Error::FromBeBytes => write!(f, "In (`FromBeBytes`): need more bytes for given type"),
            Error::Other => write!(f, "Error::Other"),
            Error::Uid(id) => write!(f, "Got error(id = {id})"),
        }
    }
}