simple_aws_s3/
error.rs

1use std::fmt;
2
3use hmac::crypto_mac::InvalidKeyLength;
4
5#[derive(Debug)]
6pub enum Error {
7    SignError(String),
8    RequestError(reqwest::Error),
9}
10
11impl fmt::Display for Error {
12    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
13        let msg = match self {
14            Self::SignError(msg) => format!("Sign Error: {}", msg),
15            Self::RequestError(e) => format!("Execute Request Error: {}", e),
16        };
17        write!(f, "{}", msg)
18    }
19}
20
21impl From<InvalidKeyLength> for Error {
22    fn from(e: InvalidKeyLength) -> Self {
23        Self::SignError(e.to_string())
24    }
25}
26
27impl From<reqwest::Error> for Error {
28    fn from(e: reqwest::Error) -> Self {
29        Self::RequestError(e)
30    }
31}