Function kvarn::prelude::networking::read_to_end_or_max
source · pub async fn read_to_end_or_max(
buffer: &mut BytesMut,
reader: impl AsyncRead + Unpin,
max_len: usize
) -> Result<(), Error>
Expand description
Reads from reader
to buffer
until it returns zero bytes or max_length
is reached. BytesMut::len
is used as a starting length of buffer
.
Note that the length of the read bytes can exceed max_len
; it stops
after having read max_len
or higher.
§Errors
Passes any errors emitted from reader
.