pub async fn read_length_delimited<S: AsyncRead + Unpin>(
    stream: &mut S,
    max_size: usize,
) -> AnyhowResult<Vec<u8>>
Expand description

A helper function to read a length-delimited message from a stream. Takes into account the maximum message size.

§Errors

  • If the message is too big
  • If we fail to read from the stream