Skip to content

Commit

Permalink
Add flush_finish()
Browse files Browse the repository at this point in the history
This function is useful for creating deflated blocks that can be concatenated.
  • Loading branch information
vandenoever committed Mar 20, 2017
1 parent b36a942 commit 6fa7e95
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/deflate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,24 @@ impl<W: Write> EncoderWriter<W> {

/// 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<W> {
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<W> {
try!(self.inner.flush());
Ok(self.inner.into_inner())
}
}

impl<W: Write> Write for EncoderWriter<W> {
Expand Down

0 comments on commit 6fa7e95

Please sign in to comment.