#![allow(clippy::all)] use std::error; use std::fmt; {{#withAWSV4Signature}} use aws_sigv4; {{/withAWSV4Signature}} #[derive(Debug, Clone)] pub struct ResponseContent { pub status: reqwest::StatusCode, pub content: String, pub entity: Option, } #[derive(Debug)] pub enum Error { Reqwest(reqwest::Error), Serde(serde_json::Error), Io(std::io::Error), ResponseError(ResponseContent), {{#withAWSV4Signature}} AWSV4SignatureError(aws_sigv4::http_request::Error), {{/withAWSV4Signature}} } impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let (module, e) = match self { Error::Reqwest(e) => ("reqwest", e.to_string()), Error::Serde(e) => ("serde", e.to_string()), Error::Io(e) => ("IO", e.to_string()), Error::ResponseError(e) => ("response", format!("status code {}", e.status)), {{#withAWSV4Signature}} Error::AWSV4SignatureError(e) => ("aws v4 signature", e.to_string()), {{/withAWSV4Signature}} }; write!(f, "error in {}: {}", module, e) } } impl error::Error for Error { fn source(&self) -> Option<&(dyn error::Error + 'static)> { Some(match self { Error::Reqwest(e) => e, Error::Serde(e) => e, Error::Io(e) => e, Error::ResponseError(_) => return None, {{#withAWSV4Signature}} Error::AWSV4SignatureError(_) => return None, {{/withAWSV4Signature}} }) } } impl From for Error { fn from(e: reqwest::Error) -> Self { Error::Reqwest(e) } } impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Serde(e) } } impl From for Error { fn from(e: std::io::Error) -> Self { Error::Io(e) } } pub fn urlencode>(s: T) -> String { ::url::form_urlencoded::byte_serialize(s.as_ref().as_bytes()).collect() } {{#apiInfo}} {{#apis}} pub mod {{{classFilename}}}; {{/apis}} {{/apiInfo}} pub mod configuration;