pub struct Response { /* private fields */ }Expand description
A high-level response wrapper providing transparent decompression and body management.
Response abstracts away the complexities of HTTP/2 stream management and
automatic decompression of browser-standard encodings.
Implementations§
Source§impl Response
impl Response
Sourcepub fn new(inner: HttpResponse<RecvStream>, url: String) -> Self
pub fn new(inner: HttpResponse<RecvStream>, url: String) -> Self
Creates a new Response from a raw H2 response and origin URL.
Sourcepub fn status(&self) -> StatusCode
pub fn status(&self) -> StatusCode
Returns the HTTP status code.
Sourcepub async fn bytes(self) -> Result<Bytes>
pub async fn bytes(self) -> Result<Bytes>
Collects the response body and returns the decompressed bytes.
This method is async as it must wait for all HTTP/2 DATA frames to arrive.
Supports gzip, br, and zstd encodings.
Sourcepub async fn json<T: DeserializeOwned>(self) -> Result<T>
pub async fn json<T: DeserializeOwned>(self) -> Result<T>
Collects the body and decodes it as JSON.
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