@@ -50,6 +50,14 @@ impl fmt::Debug for Inflate {
5050 }
5151}
5252
53+ fn flush_decompress_into_mzflush ( flush : FlushDecompress ) -> MZFlush {
54+ match flush {
55+ FlushDecompress :: None => MZFlush :: None ,
56+ FlushDecompress :: Sync => MZFlush :: Sync ,
57+ FlushDecompress :: Finish => MZFlush :: Finish ,
58+ }
59+ }
60+
5361impl InflateBackend for Inflate {
5462 fn make ( zlib_header : bool , _window_bits : u8 ) -> Self {
5563 let format = format_from_bool ( zlib_header) ;
@@ -67,8 +75,7 @@ impl InflateBackend for Inflate {
6775 output : & mut [ u8 ] ,
6876 flush : FlushDecompress ,
6977 ) -> Result < Status , DecompressError > {
70- let flush = MZFlush :: new ( flush as i32 ) . unwrap ( ) ;
71-
78+ let flush = flush_decompress_into_mzflush ( flush) ;
7279 let res = inflate:: stream:: inflate ( & mut self . inner , input, output, flush) ;
7380 self . total_in += res. bytes_consumed as u64 ;
7481 self . total_out += res. bytes_written as u64 ;
@@ -123,6 +130,15 @@ impl fmt::Debug for Deflate {
123130 }
124131}
125132
133+ fn flush_compress_into_mzflush ( flush : FlushCompress ) -> MZFlush {
134+ match flush {
135+ FlushCompress :: None => MZFlush :: None ,
136+ FlushCompress :: Sync | FlushCompress :: Partial => MZFlush :: Sync ,
137+ FlushCompress :: Full => MZFlush :: Full ,
138+ FlushCompress :: Finish => MZFlush :: Finish ,
139+ }
140+ }
141+
126142impl DeflateBackend for Deflate {
127143 fn make ( level : Compression , zlib_header : bool , _window_bits : u8 ) -> Self {
128144 // Check in case the integer value changes at some point.
@@ -145,7 +161,7 @@ impl DeflateBackend for Deflate {
145161 output : & mut [ u8 ] ,
146162 flush : FlushCompress ,
147163 ) -> Result < Status , CompressError > {
148- let flush = MZFlush :: new ( flush as i32 ) . unwrap ( ) ;
164+ let flush = flush_compress_into_mzflush ( flush) ;
149165 let res = deflate:: stream:: deflate ( & mut self . inner , input, output, flush) ;
150166 self . total_in += res. bytes_consumed as u64 ;
151167 self . total_out += res. bytes_written as u64 ;
0 commit comments