From 6fa7e95a2a1c87dddbbbdc0e89d6e6338a64c5d6 Mon Sep 17 00:00:00 2001 From: Jos van den Oever Date: Mon, 20 Mar 2017 17:48:07 +0100 Subject: [PATCH] Add flush_finish() This function is useful for creating deflated blocks that can be concatenated. --- src/deflate.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/deflate.rs b/src/deflate.rs index fc2f16f7e..a94cc234b 100644 --- a/src/deflate.rs +++ b/src/deflate.rs @@ -89,12 +89,24 @@ impl EncoderWriter { /// Consumes this encoder, flushing the output stream. /// - /// This will flush the underlying data stream and then return the contained - /// writer if the flush succeeded. + /// This will flush the underlying data stream, close off the compressed + /// stream and, if successful, return the contained writer. pub fn finish(mut self) -> io::Result { try!(self.inner.finish()); Ok(self.inner.into_inner()) } + + /// Consumes this encoder, flushing the output stream. + /// + /// This will flush the underlying data stream and then return the contained + /// writer if the flush succeeded. + /// The compressed stream will not closed but only flushed. This + /// means that obtained byte array can by extended by another deflated + /// stream. To close the stream add the two bytes 0x3 and 0x0. + pub fn flush_finish(mut self) -> io::Result { + try!(self.inner.flush()); + Ok(self.inner.into_inner()) + } } impl Write for EncoderWriter {