mz_ore::netio

Function read_exact_or_eof

Source
pub fn read_exact_or_eof<'a, A>(
    reader: &'a mut A,
    buf: &'a mut [u8],
) -> ReadExactOrEof<'a, A> 
where A: AsyncRead,
Available on crate feature network only.
Expand description

Creates a future which will read exactly enough bytes to fill buf, unless EOF is reached first. If a short read should be considered an error, use tokio::io::AsyncReadExt::read_exact instead.

The returned future will resolve to the number of bytes read.

In the case of an error the contents of the buffer are unspecified.