diff --git a/Cargo.toml b/Cargo.toml index 969d18e..3ddcc8c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,7 +32,7 @@ zstdmt = ["zstd", "zstd-safe/zstdmt"] deflate64 = ["dep:deflate64"] [dependencies] -brotli = { version = "4.0", optional = true, default-features = false, features = ["std"] } +brotli = { version = "5.0", optional = true } bzip2 = { version = "0.4.4", optional = true } flate2 = { version = "1.0.13", optional = true } futures-core = { version = "0.3", default-features = false } diff --git a/src/codec/brotli/encoder.rs b/src/codec/brotli/encoder.rs index 69f28b8..dc974e3 100644 --- a/src/codec/brotli/encoder.rs +++ b/src/codec/brotli/encoder.rs @@ -3,10 +3,7 @@ use std::{fmt, io}; use brotli::enc::{ backward_references::BrotliEncoderParams, - encode::{ - BrotliEncoderCompressStream, BrotliEncoderCreateInstance, BrotliEncoderHasMoreOutput, - BrotliEncoderIsFinished, BrotliEncoderOperation, BrotliEncoderStateStruct, - }, + encode::{BrotliEncoderOperation, BrotliEncoderStateStruct}, StandardAlloc, }; @@ -16,7 +13,7 @@ pub struct BrotliEncoder { impl BrotliEncoder { pub(crate) fn new(params: BrotliEncoderParams) -> Self { - let mut state = BrotliEncoderCreateInstance(StandardAlloc::default()); + let mut state = BrotliEncoderStateStruct::new(StandardAlloc::default()); state.params = params; Self { state } } @@ -33,8 +30,7 @@ impl BrotliEncoder { let mut input_len = 0; let mut output_len = 0; - if BrotliEncoderCompressStream( - &mut self.state, + if !self.state.compress_stream( op, &mut in_buf.len(), in_buf, @@ -44,8 +40,7 @@ impl BrotliEncoder { &mut output_len, &mut None, &mut |_, _, _, _| (), - ) <= 0 - { + ) { return Err(io::Error::new(io::ErrorKind::Other, "brotli error")); } @@ -79,7 +74,7 @@ impl Encode for BrotliEncoder { BrotliEncoderOperation::BROTLI_OPERATION_FLUSH, )?; - Ok(BrotliEncoderHasMoreOutput(&self.state) == 0) + Ok(!self.state.has_more_output()) } fn finish( @@ -92,7 +87,7 @@ impl Encode for BrotliEncoder { BrotliEncoderOperation::BROTLI_OPERATION_FINISH, )?; - Ok(BrotliEncoderIsFinished(&self.state) == 1) + Ok(self.state.is_finished()) } }