Function fake_netstack::copy_bytes

source ·
pub(crate) async fn copy_bytes<R: AsyncReadExt + Unpin, W: AsyncWriteExt + Unpin>(
    reader: R,
    writer: W,
    buffer_size: u64
) -> Result<(), Error>
Expand description

This function hand-rolls a very simple way of greedily shuttling bytes between a reader and a writer using a single buffer between them. Something like this, wrapped in a single type that is both AsyncWrite and AsyncRead with a preferably circular buffer backing it would probably be better and useful, alas it doesn’t exist in futures or async_utils at the moment of writing.