Function zng::task::io::copy

pub async fn copy<R, W>(reader: R, writer: W) -> Result<u64, Error>
where R: AsyncRead, W: AsyncWrite,
Expand description

Copies the entire contents of a reader into a writer.

This function will read data from reader and write it into writer in a streaming fashion until reader returns EOF.

On success, returns the total number of bytes copied.

ยงExamples

use futures_lite::io::{self, BufReader, BufWriter};

let input: &[u8] = b"hello";
let reader = BufReader::new(input);

let mut output = Vec::new();
let writer = BufWriter::new(&mut output);

io::copy(reader, writer).await?;