From 08c0d1422182366383eff9bb010c0b34f046a3c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Sommer?= Date: Sat, 25 Aug 2018 16:08:10 +0200 Subject: [PATCH] Add `Error(Hyper)` for errors originated from Hyper During the parsing of the HTTP responses an error might come from *Hyper*. To pass this error down to the caller, we need an entry in `Error`. --- Cargo.toml | 1 + src/lib.rs | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index b2450067..4693fd0c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,6 +13,7 @@ version = "0.5.0" [dependencies] futures = "0.1.15" http = "0.1.0" +hyper = "0.12" serde_json = "1.0.3" serde_urlencoded = "0.5.1" diff --git a/src/lib.rs b/src/lib.rs index 3846c6fb..f271f518 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,6 +14,7 @@ extern crate futures; extern crate http; +extern crate hyper; #[cfg(test)] extern crate ruma_identifiers; #[cfg(test)] @@ -45,6 +46,8 @@ pub trait Endpoint { pub enum Error { /// An HTTP error. Http(http::Error), + /// An Hyper error. + Hyper(hyper::Error), /// A I/O error. Io(io::Error), /// A Serde JSON error. @@ -65,6 +68,12 @@ impl From for Error { } } +impl From for Error { + fn from(error: hyper::Error) -> Self { + Error::Hyper(error) + } +} + impl From for Error { fn from(error: io::Error) -> Self { Error::Io(error)