pub struct Response { /* private fields */ }Implementations§
Source§impl Response
impl Response
Sourcepub fn chunk(&self, len: u64) -> Result<Option<Vec<u8>>>
pub fn chunk(&self, len: u64) -> Result<Option<Vec<u8>>>
Get a chunk of the response body.
It will block until at least one byte can be read or the stream is closed.
Sourcepub fn body(self) -> Result<Vec<u8>>
pub fn body(self) -> Result<Vec<u8>>
Get the full response body.
It will block until the stream is closed.
Sourcepub fn json<T: DeserializeOwned>(self) -> Result<T>
Available on crate feature json only.
pub fn json<T: DeserializeOwned>(self) -> Result<T>
json only.Deserialize the response body as JSON.
§Optional
This requires the json feature enabled.
#[derive(Deserialize)]
struct Data {
origin: String,
url: String,
}
let resp = Client::new().get("https://httpbin.org/get").send()?;
let json_data = resp.json::<Data>()?;Auto Trait Implementations§
impl !Freeze for Response
impl RefUnwindSafe for Response
impl Send for Response
impl Sync for Response
impl Unpin for Response
impl UnsafeUnpin for Response
impl UnwindSafe for Response
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more