forked from lx/netapp
fill_buffer do something only if buf is empty
This commit is contained in:
parent
db96af2609
commit
9362d26890
1 changed files with 5 additions and 3 deletions
|
@ -101,13 +101,15 @@ 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
|
/// Calling this might be necessary to ensure that `.eos()` returns a correct
|
||||||
/// result, otherwise the reader might not be aware that the underlying
|
/// result, otherwise the reader might not be aware that the underlying
|
||||||
/// stream has nothing left to return.
|
/// stream has nothing left to return.
|
||||||
pub async fn fill_buffer(&mut self) {
|
pub async fn fill_buffer(&mut self) {
|
||||||
let packet = self.stream.next().await;
|
if self.buf.is_empty() {
|
||||||
self.add_stream_next(packet);
|
let packet = self.stream.next().await;
|
||||||
|
self.add_stream_next(packet);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Clears the internal read buffer and returns its content
|
/// Clears the internal read buffer and returns its content
|
||||||
|
|
Loading…
Reference in a new issue