diff --git a/src/zlib/bufread.rs b/src/zlib/bufread.rs index 85bbd38a..07a7ebe3 100644 --- a/src/zlib/bufread.rs +++ b/src/zlib/bufread.rs @@ -217,6 +217,16 @@ impl ZlibDecoder { &mut self.obj } + /// Acquires a reference to the underlying `Decompress` instance + pub fn get_data(&self) -> &Decompress { + &self.data + } + + /// Acquires a mutable reference to the underlying `Decompress` instance + pub fn get_data_mut(&mut self) -> &mut Decompress { + &mut self.data + } + /// Consumes this decoder, returning the underlying reader. pub fn into_inner(self) -> R { self.obj diff --git a/src/zlib/read.rs b/src/zlib/read.rs index 3b41ae6c..f53509f0 100644 --- a/src/zlib/read.rs +++ b/src/zlib/read.rs @@ -222,6 +222,22 @@ impl ZlibDecoder { self.inner.get_mut().reset(r) } + /// Resets the state of the decoder entirely + /// Opposed to `reset`, this function takes into account that there was + /// previously a custom Decompress in place + /// + /// `zlib_header` should be whatever was used before in `new_with_decompress` + pub fn reset_on_custom(&mut self, r: R, zlib_header: bool) -> R { + self.inner.get_data_mut().reset(zlib_header); + self.inner.get_mut().reset(r) + } + + /// Resets the stream for another, without wiping the bufreader. + /// Use this when your 2nd stream is dependant on previous' streams. + pub fn continue_read(&mut self, r: R) -> R { + self.inner.get_mut().reset(r) + } + /// Acquires a reference to the underlying stream pub fn get_ref(&self) -> &R { self.inner.get_ref().get_ref()