diff options
author | softprops <d.tangren@gmail.com> | 2016-01-03 19:27:51 -0500 |
---|---|---|
committer | softprops <d.tangren@gmail.com> | 2016-01-03 19:27:51 -0500 |
commit | 58b0f0a1831622ba5d69a1ab2ce562580a0c80ab (patch) | |
tree | d15c2acfd0ce7d3f236c0dd9bce9678e04a345fc /src/transport.rs | |
parent | df827431603ae817faaf1c6bc5fbf2a003302865 (diff) |
rustfmt
Diffstat (limited to 'src/transport.rs')
-rw-r--r-- | src/transport.rs | 49 |
1 files changed, 33 insertions, 16 deletions
diff --git a/src/transport.rs b/src/transport.rs index f22027e..bed9fd1 100644 --- a/src/transport.rs +++ b/src/transport.rs @@ -40,11 +40,7 @@ impl fmt::Debug for Transport { } impl Transport { - pub fn request(&self, - method: Method, - endpoint: &str, - body: Option<Body>) - -> Result<String> { + pub fn request(&self, method: Method, endpoint: &str, body: Option<Body>) -> Result<String> { let mut res = match self.stream(method, endpoint, body) { Ok(r) => r, Err(e) => panic!("failed request {:?}", e), @@ -54,11 +50,7 @@ impl Transport { Ok(body) } - pub fn stream(&self, - method: Method, - endpoint: &str, - body: Option<Body>) - -> Result<Box<Read>> { + pub fn stream(&self, method: Method, endpoint: &str, body: Option<Body>) -> Result<Box<Read>> { let req = match *self { Transport::Tcp { ref client, ref host } => { client.request(method, &format!("{}{}", host, endpoint)[..]) @@ -82,12 +74,37 @@ impl Transport { } StatusCode::NoContent => Ok(Box::new(BufReader::new("".as_bytes()))), // todo: constantize these - StatusCode::BadRequest => Err(Error::Fault { code: res.status, message: "bad parameter".to_owned() }), - StatusCode::NotFound => Err(Error::Fault { code: res.status, message: "not found".to_owned() }), - StatusCode::NotAcceptable => Err(Error::Fault { code: res.status, message: "not acceptable".to_owned() }), - StatusCode::Conflict => Err(Error::Fault { code: res.status, message: "conflict found".to_owned() }), - StatusCode::InternalServerError => Err(Error::Fault{ code: res.status, message: "internal server error".to_owned() }), - _ => unreachable!() + StatusCode::BadRequest => { + Err(Error::Fault { + code: res.status, + message: "bad parameter".to_owned(), + }) + } + StatusCode::NotFound => { + Err(Error::Fault { + code: res.status, + message: "not found".to_owned(), + }) + } + StatusCode::NotAcceptable => { + Err(Error::Fault { + code: res.status, + message: "not acceptable".to_owned(), + }) + } + StatusCode::Conflict => { + Err(Error::Fault { + code: res.status, + message: "conflict found".to_owned(), + }) + } + StatusCode::InternalServerError => { + Err(Error::Fault { + code: res.status, + message: "internal server error".to_owned(), + }) + } + _ => unreachable!(), } } } |