fill_buffer do something only if buf is empty
Some checks reported errors
continuous-integration/drone/push Build was killed
continuous-integration/drone/pr Build was killed

This commit is contained in:
Alex 2022-09-13 12:08:33 +02:00
parent db96af2609
commit 9362d26890
Signed by: lx
GPG key ID: 0E496D15096376BE

View file

@ -101,14 +101,16 @@ impl ByteStreamReader {
}
}
/// Tries to fill the internal read buffer from the underlying stream.
/// Tries to fill the internal read buffer from the underlying stream if it is empty.
/// Calling this might be necessary to ensure that `.eos()` returns a correct
/// result, otherwise the reader might not be aware that the underlying
/// stream has nothing left to return.
pub async fn fill_buffer(&mut self) {
if self.buf.is_empty() {
let packet = self.stream.next().await;
self.add_stream_next(packet);
}
}
/// Clears the internal read buffer and returns its content
pub fn take_buffer(&mut self) -> Bytes {