1use openssl::error::ErrorStack;
18use quick_xml::DeError;
19use std::{fmt, io};
20
21#[derive(Debug)]
22pub enum Error {
23 IOError(String),
24 InvalidCert(String),
25 InvalidResponse(String),
26}
27
28impl fmt::Display for Error {
29 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
30 match &self {
31 Self::IOError(s) => write!(f, "IO Error: {}", s),
32 Self::InvalidCert(s) => write!(f, "Invalid Cert: {}", s),
33 Self::InvalidResponse(s) => write!(f, "Invalid Response: {}", s),
34 }
35 }
36}
37
38impl std::error::Error for Error {}
39
40impl From<io::Error> for Error {
41 fn from(err: io::Error) -> Self {
42 Self::IOError(err.to_string())
43 }
44}
45
46impl From<ErrorStack> for Error {
47 fn from(err: ErrorStack) -> Self {
48 Self::InvalidCert(err.to_string())
49 }
50}
51
52impl From<DeError> for Error {
53 fn from(err: DeError) -> Self {
54 Self::InvalidResponse(err.to_string())
55 }
56}
57
58pub type Result<T> = std::result::Result<T, Error>;