Add rustls support (#390)
This commit is contained in:
		
							
								
								
									
										39
									
								
								src/error.rs
									
									
									
									
									
								
							
							
						
						
									
										39
									
								
								src/error.rs
									
									
									
									
									
								
							| @@ -135,8 +135,12 @@ impl Error { | ||||
|             Kind::Hyper(ref e) => Some(e), | ||||
|             Kind::Mime(ref e) => Some(e), | ||||
|             Kind::Url(ref e) => Some(e), | ||||
|             #[cfg(all(feature = "default-tls", feature = "rustls-tls"))] | ||||
|             Kind::Incompatible => None, | ||||
|             #[cfg(feature = "default-tls")] | ||||
|             Kind::Tls(ref e) => Some(e), | ||||
|             Kind::NativeTls(ref e) => Some(e), | ||||
|             #[cfg(feature = "rustls-tls")] | ||||
|             Kind::Rustls(ref e) => Some(e), | ||||
|             Kind::Io(ref e) => Some(e), | ||||
|             Kind::UrlEncoded(ref e) => Some(e), | ||||
|             Kind::Json(ref e) => Some(e), | ||||
| @@ -225,8 +229,12 @@ impl fmt::Display for Error { | ||||
|             Kind::Mime(ref e) => fmt::Display::fmt(e, f), | ||||
|             Kind::Url(ref e) => fmt::Display::fmt(e, f), | ||||
|             Kind::UrlBadScheme => f.write_str("URL scheme is not allowed"), | ||||
|             #[cfg(all(feature = "default-tls", feature = "rustls-tls"))] | ||||
|             Kind::Incompatible => f.write_str("Incompatible identity type"), | ||||
|             #[cfg(feature = "default-tls")] | ||||
|             Kind::Tls(ref e) => fmt::Display::fmt(e, f), | ||||
|             Kind::NativeTls(ref e) => fmt::Display::fmt(e, f), | ||||
|             #[cfg(feature = "rustls-tls")] | ||||
|             Kind::Rustls(ref e) => fmt::Display::fmt(e, f), | ||||
|             Kind::Io(ref e) => fmt::Display::fmt(e, f), | ||||
|             Kind::UrlEncoded(ref e) => fmt::Display::fmt(e, f), | ||||
|             Kind::Json(ref e) => fmt::Display::fmt(e, f), | ||||
| @@ -252,8 +260,12 @@ impl StdError for Error { | ||||
|             Kind::Mime(ref e) => e.description(), | ||||
|             Kind::Url(ref e) => e.description(), | ||||
|             Kind::UrlBadScheme => "URL scheme is not allowed", | ||||
|             #[cfg(all(feature = "default-tls", feature = "rustls-tls"))] | ||||
|             Kind::Incompatible => "Incompatible identity type", | ||||
|             #[cfg(feature = "default-tls")] | ||||
|             Kind::Tls(ref e) => e.description(), | ||||
|             Kind::NativeTls(ref e) => e.description(), | ||||
|             #[cfg(feature = "rustls-tls")] | ||||
|             Kind::Rustls(ref e) => e.description(), | ||||
|             Kind::Io(ref e) => e.description(), | ||||
|             Kind::UrlEncoded(ref e) => e.description(), | ||||
|             Kind::Json(ref e) => e.description(), | ||||
| @@ -270,8 +282,12 @@ impl StdError for Error { | ||||
|             Kind::Hyper(ref e) => e.cause(), | ||||
|             Kind::Mime(ref e) => e.cause(), | ||||
|             Kind::Url(ref e) => e.cause(), | ||||
|             #[cfg(all(feature = "default-tls", feature = "rustls-tls"))] | ||||
|             Kind::Incompatible => None, | ||||
|             #[cfg(feature = "default-tls")] | ||||
|             Kind::Tls(ref e) => e.cause(), | ||||
|             Kind::NativeTls(ref e) => e.cause(), | ||||
|             #[cfg(feature = "rustls-tls")] | ||||
|             Kind::Rustls(ref e) => e.cause(), | ||||
|             Kind::Io(ref e) => e.cause(), | ||||
|             Kind::UrlEncoded(ref e) => e.cause(), | ||||
|             Kind::Json(ref e) => e.cause(), | ||||
| @@ -291,8 +307,12 @@ pub(crate) enum Kind { | ||||
|     Mime(::mime::FromStrError), | ||||
|     Url(::url::ParseError), | ||||
|     UrlBadScheme, | ||||
|     #[cfg(all(feature = "default-tls", feature = "rustls-tls"))] | ||||
|     Incompatible, | ||||
|     #[cfg(feature = "default-tls")] | ||||
|     Tls(::native_tls::Error), | ||||
|     NativeTls(::native_tls::Error), | ||||
|     #[cfg(feature = "rustls-tls")] | ||||
|     Rustls(::rustls::TLSError), | ||||
|     Io(io::Error), | ||||
|     UrlEncoded(::serde_urlencoded::ser::Error), | ||||
|     Json(::serde_json::Error), | ||||
| @@ -355,7 +375,14 @@ impl From<::serde_json::Error> for Kind { | ||||
| #[cfg(feature = "default-tls")] | ||||
| impl From<::native_tls::Error> for Kind { | ||||
|     fn from(err: ::native_tls::Error) -> Kind { | ||||
|         Kind::Tls(err) | ||||
|         Kind::NativeTls(err) | ||||
|     } | ||||
| } | ||||
|  | ||||
| #[cfg(feature = "rustls-tls")] | ||||
| impl From<::rustls::TLSError> for Kind { | ||||
|     fn from(err: ::rustls::TLSError) -> Kind { | ||||
|         Kind::Rustls(err) | ||||
|     } | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user