//! Utilities. //! //! Taken from . use bytes::{Bytes, BytesMut}; use tokio::io::{AsyncRead, AsyncReadExt}; /// Greedily reads from a stream to fill a buffer. pub async fn read_chunk_async( stream: &mut S, mut chunk: BytesMut, ) -> std::io::Result { while chunk.len() < chunk.capacity() { let read = stream.read_buf(&mut chunk).await?; if read == 0 { break; } } Ok(chunk.freeze()) }