Skip to content

Commit

Permalink
finish brotli output when into_inner is called
Browse files Browse the repository at this point in the history
  • Loading branch information
danielrh committed Feb 11, 2019
1 parent a826cf1 commit 1910467
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "brotli"
version = "3.2.0"
version = "3.2.1"
authors = ["Daniel Reiter Horn <danielrh@dropbox.com>", "The Brotli Authors"]
description = "A brotli compressor and decompressor that with an interface avoiding the rust stdlib. This makes it suitable for embedded devices and kernels. It is designed with a pluggable allocator so that the standard lib's allocator may be employed. The default build also includes a stdlib allocator and stream interface. Disable this with --features=no-stdlib. All included code is safe."
license = "BSD-3-Clause/MIT"
Expand Down
10 changes: 8 additions & 2 deletions src/enc/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,10 @@ CompressorWriterCustomIo<ErrType, W, BufferType, Alloc>
self.output.as_ref().unwrap()
}
pub fn into_inner(mut self) -> W {
match self.flush_or_close(BrotliEncoderOperation::BROTLI_OPERATION_FINISH) {
Ok(_) => {},
Err(_) => {},
}
core::mem::replace(&mut self.output, None).unwrap()
}
}
Expand All @@ -223,9 +227,11 @@ impl<ErrType,
Alloc: BrotliAlloc> Drop for
CompressorWriterCustomIo<ErrType, W, BufferType, Alloc> {
fn drop(&mut self) {
match self.flush_or_close(BrotliEncoderOperation::BROTLI_OPERATION_FINISH) {
Ok(_) => {},
if self.output.is_some() {
match self.flush_or_close(BrotliEncoderOperation::BROTLI_OPERATION_FINISH) {
Ok(_) => {},
Err(_) => {},
}
}
BrotliEncoderDestroyInstance(&mut self.state);
}
Expand Down

0 comments on commit 1910467

Please sign in to comment.