Skip to content

Commit

Permalink
Add a BufRead implementation for CrcReader
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcrichton committed Feb 7, 2016
1 parent 98874c3 commit bb5d7c9
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/crc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,15 @@ impl<R: Read> Read for CrcReader<R> {
Ok(amt)
}
}

impl<R: BufRead> BufRead for CrcReader<R> {
fn fill_buf(&mut self) -> io::Result<&[u8]> {
self.inner.fill_buf()
}
fn consume(&mut self, amt: usize) {
if let Ok(data) = self.inner.fill_buf() {
self.crc.update(&data[..amt]);
}
self.inner.consume(amt);
}
}

0 comments on commit bb5d7c9

Please sign in to comment.