[][src]Trait isahc::AsyncReadResponseExt

pub trait AsyncReadResponseExt<R: AsyncRead + Unpin> {
    pub fn copy_to<'a, W>(&'a mut self, writer: W) -> CopyFuture<'a, R, W>
    where
        W: AsyncWrite + Unpin + 'a
;
pub fn text(&mut self) -> TextFuture<'_, &mut R>; }

Provides extension methods for consuming asynchronous HTTP response streams.

Required methods

pub fn copy_to<'a, W>(&'a mut self, writer: W) -> CopyFuture<'a, R, W> where
    W: AsyncWrite + Unpin + 'a, 
[src]

Copy the response body into a writer asynchronously.

Returns the number of bytes that were written.

Examples

Copying the response into an in-memory buffer:

use isahc::prelude::*;

let mut buf = vec![];
isahc::get_async("https://example.org").await?
    .copy_to(&mut buf).await?;
println!("Read {} bytes", buf.len());

pub fn text(&mut self) -> TextFuture<'_, &mut R>[src]

Read the response body as a string asynchronously.

This method consumes the entire response body stream and can only be called once.

Availability

This method is only available when the text-decoding feature is enabled, which it is by default.

Examples

use isahc::prelude::*;

let text = isahc::get_async("https://example.org").await?
    .text().await?;
println!("{}", text);
Loading content...

Implementors

impl<R: AsyncRead + Unpin> AsyncReadResponseExt<R> for Response<R>[src]

Loading content...