From e3bf6756f4fd9f792ece06b601b8241c7e90d455 Mon Sep 17 00:00:00 2001 From: Michal Budzynski Date: Sun, 4 Jun 2017 04:49:33 +0200 Subject: [PATCH] Added missing "Errors" and "Panics" sections to request.rs and response.rs --- src/request.rs | 15 +++++++++++++++ src/response.rs | 7 +++++++ 2 files changed, 22 insertions(+) diff --git a/src/request.rs b/src/request.rs index 5d8b3e6..0cb7781 100644 --- a/src/request.rs +++ b/src/request.rs @@ -153,6 +153,11 @@ impl RequestBuilder { /// # Ok(()) /// # } /// ``` + /// + /// # Errors + /// + /// This method fails if the passed value cannot be serialized into + /// url encoded format pub fn form(&mut self, form: &T) -> ::Result<&mut RequestBuilder> { { // check request_mut() before running serde @@ -202,6 +207,11 @@ impl RequestBuilder { /// Build a `Request`, which can be inspected, modified and executed with /// `Client::execute()`. + /// + /// # Panics + /// + /// This method consumes builder internal state. It panics on an attempt to + /// reuse already consumed builder. pub fn build(&mut self) -> Request { self.request .take() @@ -209,6 +219,11 @@ impl RequestBuilder { } /// Constructs the Request and sends it the target URL, returning a Response. + /// + /// # Errors + /// + /// This method fails if there was an error while sending request, + /// redirect loop was detected or redirect limit was exhausted. pub fn send(&mut self) -> ::Result<::Response> { let request = self.build(); self.client.execute(request) diff --git a/src/response.rs b/src/response.rs index cf3d3ea..8848ca9 100644 --- a/src/response.rs +++ b/src/response.rs @@ -100,6 +100,13 @@ impl Response { /// # } /// # } /// ``` + /// + /// # Errors + /// + /// This method fails whenever the response body is not in JSON format + /// or it cannot be properly deserialized to target type `T`. For more + /// details please see [`serde_json::from_reader`]. + /// [`serde_json::from_reader`]: https://docs.serde.rs/serde_json/fn.from_reader.html #[inline] pub fn json(&mut self) -> ::Result { serde_json::from_reader(self).map_err(::error::from)