@@ -50,6 +50,16 @@ impl fmt::Debug for Inflate {
5050 }
5151}
5252
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+
5363impl InflateBackend for Inflate {
5464 fn make ( zlib_header : bool , _window_bits : u8 ) -> Self {
5565 let format = format_from_bool ( zlib_header) ;
@@ -67,9 +77,8 @@ impl InflateBackend for Inflate {
6777 output : & mut [ u8 ] ,
6878 flush : FlushDecompress ,
6979 ) -> 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) ;
7382 self . total_in += res. bytes_consumed as u64 ;
7483 self . total_out += res. bytes_written as u64 ;
7584
@@ -123,6 +132,17 @@ impl fmt::Debug for Deflate {
123132 }
124133}
125134
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+
126146impl DeflateBackend for Deflate {
127147 fn make ( level : Compression , zlib_header : bool , _window_bits : u8 ) -> Self {
128148 // Check in case the integer value changes at some point.
@@ -145,8 +165,8 @@ impl DeflateBackend for Deflate {
145165 output : & mut [ u8 ] ,
146166 flush : FlushCompress ,
147167 ) -> 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 ) ;
150170 self . total_in += res. bytes_consumed as u64 ;
151171 self . total_out += res. bytes_written as u64 ;
152172
0 commit comments