From fb81b08747fe8105bb9bed2b44039be6b5da3475 Mon Sep 17 00:00:00 2001 From: Jonathan Behrens Date: Mon, 28 Oct 2024 20:15:56 -0700 Subject: [PATCH] Pass-through implementations for more trait methods --- src/hooks.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/hooks.rs b/src/hooks.rs index 25938af547..116567dea1 100644 --- a/src/hooks.rs +++ b/src/hooks.rs @@ -21,6 +21,18 @@ impl Read for GenericReader<'_> { fn read(&mut self, buf: &mut [u8]) -> std::io::Result { self.0.read(buf) } + fn read_vectored(&mut self, bufs: &mut [std::io::IoSliceMut<'_>]) -> std::io::Result { + self.0.read_vectored(bufs) + } + fn read_to_end(&mut self, buf: &mut Vec) -> std::io::Result { + self.0.read_to_end(buf) + } + fn read_to_string(&mut self, buf: &mut String) -> std::io::Result { + 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]> { @@ -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) -> std::io::Result { + self.0.read_until(byte, buf) + } + fn read_line(&mut self, buf: &mut String) -> std::io::Result { + self.0.read_line(buf) + } } impl Seek for GenericReader<'_> { fn seek(&mut self, pos: std::io::SeekFrom) -> std::io::Result { self.0.seek(pos) } + fn rewind(&mut self) -> std::io::Result<()> { + self.0.rewind() + } + fn stream_position(&mut self) -> std::io::Result { + 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.