Skip to main content

copy

Function copy 

Source
pub async fn copy<R, W>(reader: &mut R, writer: &mut W) -> Result<u64>
where R: AsyncRead + Unpin + ?Sized, W: AsyncWrite + Unpin + ?Sized,
Expand description

Copies everything reader gives into writer, then flushes it; answers the bytes copied.

let mut reader: &[u8] = b"hello";
let mut writer = Vec::new();
let copied = nuclei::io::copy(&mut reader, &mut writer).await.unwrap();
assert_eq!(copied, 5);
assert_eq!(writer, b"hello");