kvarn::prelude::internals

Function 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 max_len is a suggestion and will probably be overran.

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.