Struct edjx::FetchResponse

source ·
pub struct FetchResponse { /* private fields */ }
Expand description

Response for HTTP fetch request, which may include body, headers, and status code.

use edjx::{FetchResponse, HttpFetch, StatusCode, Uri};
use std::str::FromStr;

let fetch_uri = Uri::from_str("https://httpbin.org/get").unwrap();
let mut fetch_res: FetchResponse = match HttpFetch::get(fetch_uri).send() {
   Ok(resp) => resp,
   Err(e) => {
       panic!("{}", &e.to_string());
   }
};

let body = fetch_res.read_body();
assert_eq!(fetch_res.status_code(), &StatusCode::OK);

Implementations§

Returns the HTTP status code of the fetch response.

Returns the HTTP header map of the fetch response.

Reads and returns the HTTP body of the fetch response.

This method should not be called more than once.

Returns the HTTP body of the fetch response as a read stream.

Trait Implementations§

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.