diff --git a/src/iter.rs b/src/iter.rs index c4e8d160..cef0dddd 100644 --- a/src/iter.rs +++ b/src/iter.rs @@ -200,6 +200,24 @@ impl tokio::io::AsyncSeek for ProgressBarIter tokio::io::AsyncBufRead + for ProgressBarIter +{ + fn poll_fill_buf(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { + let this = self.get_mut(); + let result = Pin::new(&mut this.it).poll_fill_buf(cx); + if let Poll::Ready(Ok(buf)) = &result { + this.progress.inc(buf.len() as u64); + } + result + } + + fn consume(mut self: Pin<&mut Self>, amt: usize) { + Pin::new(&mut self.it).consume(amt); + } +} + impl io::Write for ProgressBarIter { fn write(&mut self, buf: &[u8]) -> io::Result { self.it.write(buf).map(|inc| {