[][src]Function futures_lite::io::copy

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

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 blocking::Unblock;
use futures_lite::*;

let reader: &[u8] = b"hello";
let writer = Unblock::new(std::io::stdout());

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