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
use reqwest::StatusCode;

pub type Result<T> = std::result::Result<T, Error>;

pub enum Error {
    IoError(std::io::Error),
    RequestError(reqwest::Error),
    DeError(quick_xml::DeError),
    ResponseError(StatusCode),
    Utf8Error(std::str::Utf8Error)
}

impl From<std::io::Error> for Error {
    fn from(value: std::io::Error) -> Self {
        Self::IoError(value)
    }
}
impl From<reqwest::Error> for Error {
    fn from(value: reqwest::Error) -> Self {
        Self::RequestError(value)
    }
}
impl From<quick_xml::DeError> for Error {
    fn from(value: quick_xml::DeError) -> Self {
        Self::DeError(value)
    }
}
impl From<std::str::Utf8Error> for Error {
    fn from(value: std::str::Utf8Error) -> Self {
        Self::Utf8Error(value)
    }
}

impl std::fmt::Debug for Error {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            Self::IoError(arg0) => arg0.fmt(f),
            Self::RequestError(arg0) =>arg0.fmt(f),
            Self::DeError(arg0) => arg0.fmt(f),
            Self::ResponseError(arg) => arg.fmt(f),
            Error::Utf8Error(arg) => arg.fmt(f),
        }
    }
}

impl std::fmt::Display for Error {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            Self::IoError(arg0) => arg0.fmt(f),
            Self::RequestError(arg0) =>arg0.fmt(f),
            Self::DeError(arg0) => arg0.fmt(f),
            Self::ResponseError(arg) => arg.fmt(f),
            Self::Utf8Error(arg) => arg.fmt(f)
        }
    }
}
impl std::error::Error for Error {
    
}