Function completion::io::copy_buf[][src]

pub fn copy_buf<'a, R: AsyncBufRead + ?Sized, W: AsyncWrite + ?Sized>(
    reader: &'a mut R,
    writer: &'a mut W
) -> CopyBuf<'a, R, W>

Notable traits for CopyBuf<'a, R, W>

impl<'a, R: ?Sized, W: ?Sized> Future for CopyBuf<'a, R, W> where
    R: 'a + AsyncBufRead,
    W: 'a + AsyncWrite,
    <R as AsyncBufReadWith<'a>>::FillBufFuture: Future<Output = Result<&'a [u8]>>,
    <W as AsyncWriteWith<'a>>::WriteFuture: Future<Output = Result<u64>>,
    <W as AsyncWriteWith<'a>>::FlushFuture: Future<Output = Result<()>>, 
type Output = Result<u64>;
This is supported on crate feature std only.

Copy the entire contents of a buffered reader into a writer.

When you have a buffered reader, than is more efficient than calling copy. See copy for more details about the semantics and errors of this function.

Unlike copy, this flushes the reader once it is complete.

Examples

let mut reader: &[u8] = b"Lorem ipsum dolor sit amet";
let mut writer = Vec::new();

completion::io::copy_buf(&mut reader, &mut writer).await?;

assert_eq!(writer, b"Lorem ipsum dolor sit amet");