@@ -3,10 +3,7 @@ use std::{fmt, io};
3
3
4
4
use brotli:: enc:: {
5
5
backward_references:: BrotliEncoderParams ,
6
- encode:: {
7
- BrotliEncoderCompressStream , BrotliEncoderCreateInstance , BrotliEncoderHasMoreOutput ,
8
- BrotliEncoderIsFinished , BrotliEncoderOperation , BrotliEncoderStateStruct ,
9
- } ,
6
+ encode:: { BrotliEncoderOperation , BrotliEncoderStateStruct } ,
10
7
StandardAlloc ,
11
8
} ;
12
9
@@ -16,7 +13,7 @@ pub struct BrotliEncoder {
16
13
17
14
impl BrotliEncoder {
18
15
pub ( crate ) fn new ( params : BrotliEncoderParams ) -> Self {
19
- let mut state = BrotliEncoderCreateInstance ( StandardAlloc :: default ( ) ) ;
16
+ let mut state = BrotliEncoderStateStruct :: new ( StandardAlloc :: default ( ) ) ;
20
17
state. params = params;
21
18
Self { state }
22
19
}
@@ -33,8 +30,7 @@ impl BrotliEncoder {
33
30
let mut input_len = 0 ;
34
31
let mut output_len = 0 ;
35
32
36
- if BrotliEncoderCompressStream (
37
- & mut self . state ,
33
+ if !self . state . compress_stream (
38
34
op,
39
35
& mut in_buf. len ( ) ,
40
36
in_buf,
@@ -44,8 +40,7 @@ impl BrotliEncoder {
44
40
& mut output_len,
45
41
& mut None ,
46
42
& mut |_, _, _, _| ( ) ,
47
- ) <= 0
48
- {
43
+ ) {
49
44
return Err ( io:: Error :: new ( io:: ErrorKind :: Other , "brotli error" ) ) ;
50
45
}
51
46
@@ -79,7 +74,7 @@ impl Encode for BrotliEncoder {
79
74
BrotliEncoderOperation :: BROTLI_OPERATION_FLUSH ,
80
75
) ?;
81
76
82
- Ok ( BrotliEncoderHasMoreOutput ( & self . state ) == 0 )
77
+ Ok ( ! self . state . has_more_output ( ) )
83
78
}
84
79
85
80
fn finish (
@@ -92,7 +87,7 @@ impl Encode for BrotliEncoder {
92
87
BrotliEncoderOperation :: BROTLI_OPERATION_FINISH ,
93
88
) ?;
94
89
95
- Ok ( BrotliEncoderIsFinished ( & self . state ) == 1 )
90
+ Ok ( self . state . is_finished ( ) )
96
91
}
97
92
}
98
93
0 commit comments