pub trait ResponseExt: Sized {
// Required methods
async fn body_bytes(self) -> Result<Bytes, OxiHttpError>;
async fn body_text(self) -> Result<String, OxiHttpError>;
async fn body_json<T: DeserializeOwned>(self) -> Result<T, OxiHttpError>;
}Expand description
Extension methods for http::Response<B> where B implements
http_body::Body.
Provided for any response type where the body can be buffered
asynchronously. The trait methods consume self (the response).
§Example
ⓘ
use oxihttp_core::ResponseExt;
let text = response.body_text().await?;
let value: MyStruct = response.body_json().await?;Required Methods§
Sourceasync fn body_bytes(self) -> Result<Bytes, OxiHttpError>
async fn body_bytes(self) -> Result<Bytes, OxiHttpError>
Consume the response and collect all body bytes into a single Bytes.
Sourceasync fn body_text(self) -> Result<String, OxiHttpError>
async fn body_text(self) -> Result<String, OxiHttpError>
Consume the response and decode the body as a UTF-8 string.
Sourceasync fn body_json<T: DeserializeOwned>(self) -> Result<T, OxiHttpError>
async fn body_json<T: DeserializeOwned>(self) -> Result<T, OxiHttpError>
Consume the response and deserialize the body as JSON.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".