@@ -50,6 +50,16 @@ impl fmt::Debug for Inflate {
50
50
}
51
51
}
52
52
53
+ impl From < FlushDecompress > for MZFlush {
54
+ fn from ( value : FlushDecompress ) -> Self {
55
+ match value {
56
+ FlushDecompress :: None => Self :: None ,
57
+ FlushDecompress :: Sync => Self :: Sync ,
58
+ FlushDecompress :: Finish => Self :: Finish ,
59
+ }
60
+ }
61
+ }
62
+
53
63
impl InflateBackend for Inflate {
54
64
fn make ( zlib_header : bool , _window_bits : u8 ) -> Self {
55
65
let format = format_from_bool ( zlib_header) ;
@@ -67,9 +77,8 @@ impl InflateBackend for Inflate {
67
77
output : & mut [ u8 ] ,
68
78
flush : FlushDecompress ,
69
79
) -> Result < Status , DecompressError > {
70
- let flush = MZFlush :: new ( flush as i32 ) . unwrap ( ) ;
71
-
72
- let res = inflate:: stream:: inflate ( & mut self . inner , input, output, flush) ;
80
+ let mz_flush = flush. into ( ) ;
81
+ let res = inflate:: stream:: inflate ( & mut self . inner , input, output, mz_flush) ;
73
82
self . total_in += res. bytes_consumed as u64 ;
74
83
self . total_out += res. bytes_written as u64 ;
75
84
@@ -123,6 +132,17 @@ impl fmt::Debug for Deflate {
123
132
}
124
133
}
125
134
135
+ impl From < FlushCompress > for MZFlush {
136
+ fn from ( value : FlushCompress ) -> Self {
137
+ match value {
138
+ FlushCompress :: None => Self :: None ,
139
+ FlushCompress :: Partial | FlushCompress :: Sync => Self :: Sync ,
140
+ FlushCompress :: Full => Self :: Full ,
141
+ FlushCompress :: Finish => Self :: Finish ,
142
+ }
143
+ }
144
+ }
145
+
126
146
impl DeflateBackend for Deflate {
127
147
fn make ( level : Compression , zlib_header : bool , _window_bits : u8 ) -> Self {
128
148
// Check in case the integer value changes at some point.
@@ -145,8 +165,8 @@ impl DeflateBackend for Deflate {
145
165
output : & mut [ u8 ] ,
146
166
flush : FlushCompress ,
147
167
) -> Result < Status , CompressError > {
148
- let flush = MZFlush :: new ( flush as i32 ) . unwrap ( ) ;
149
- let res = deflate:: stream:: deflate ( & mut self . inner , input, output, flush ) ;
168
+ let mz_flush = flush. into ( ) ;
169
+ let res = deflate:: stream:: deflate ( & mut self . inner , input, output, mz_flush ) ;
150
170
self . total_in += res. bytes_consumed as u64 ;
151
171
self . total_out += res. bytes_written as u64 ;
152
172
0 commit comments