Skip to content

Commit

Permalink
Pass-through implementations for more trait methods
Browse files Browse the repository at this point in the history
  • Loading branch information
fintelia committed Oct 29, 2024
1 parent 74231d8 commit fb81b08
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/hooks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ impl Read for GenericReader<'_> {
fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> {
self.0.read(buf)
}
fn read_vectored(&mut self, bufs: &mut [std::io::IoSliceMut<'_>]) -> std::io::Result<usize> {
self.0.read_vectored(bufs)
}
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> std::io::Result<usize> {
self.0.read_to_end(buf)
}
fn read_to_string(&mut self, buf: &mut String) -> std::io::Result<usize> {
self.0.read_to_string(buf)
}
fn read_exact(&mut self, buf: &mut [u8]) -> std::io::Result<()> {
self.0.read_exact(buf)
}
}
impl BufRead for GenericReader<'_> {
fn fill_buf(&mut self) -> std::io::Result<&[u8]> {
Expand All @@ -29,11 +41,25 @@ impl BufRead for GenericReader<'_> {
fn consume(&mut self, amt: usize) {
self.0.consume(amt)
}
fn read_until(&mut self, byte: u8, buf: &mut Vec<u8>) -> std::io::Result<usize> {
self.0.read_until(byte, buf)
}
fn read_line(&mut self, buf: &mut String) -> std::io::Result<usize> {
self.0.read_line(buf)
}
}
impl Seek for GenericReader<'_> {
fn seek(&mut self, pos: std::io::SeekFrom) -> std::io::Result<u64> {
self.0.seek(pos)
}
fn rewind(&mut self) -> std::io::Result<()> {
self.0.rewind()
}
fn stream_position(&mut self) -> std::io::Result<u64> {
self.0.stream_position()
}

// TODO: Add `seek_relative` once MSRV is at least 1.80.0
}

/// A function to produce an `ImageDecoder` for a given image format.
Expand Down

0 comments on commit fb81b08

Please sign in to comment.