@@ -50,11 +50,13 @@ 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 ,
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+ }
5860 }
5961}
6062
@@ -75,8 +77,8 @@ impl InflateBackend for Inflate {
7577 output : & mut [ u8 ] ,
7678 flush : FlushDecompress ,
7779 ) -> Result < Status , DecompressError > {
78- let flush = flush_decompress_into_mzflush ( flush) ;
79- 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 ) ;
8082 self . total_in += res. bytes_consumed as u64 ;
8183 self . total_out += res. bytes_written as u64 ;
8284
@@ -130,12 +132,14 @@ impl fmt::Debug for Deflate {
130132 }
131133}
132134
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 ,
135+ impl From < FlushCompress > for MZFlush {
136+ fn from ( value : FlushCompress ) -> Self {
137+ match value {
138+ FlushCompress :: None => Self :: None ,
139+ FlushCompress :: Sync | FlushCompress :: Partial => Self :: Sync ,
140+ FlushCompress :: Full => Self :: Full ,
141+ FlushCompress :: Finish => Self :: Finish ,
142+ }
139143 }
140144}
141145
@@ -161,8 +165,8 @@ impl DeflateBackend for Deflate {
161165 output : & mut [ u8 ] ,
162166 flush : FlushCompress ,
163167 ) -> Result < Status , CompressError > {
164- let flush = flush_compress_into_mzflush ( flush) ;
165- 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 ) ;
166170 self . total_in += res. bytes_consumed as u64 ;
167171 self . total_out += res. bytes_written as u64 ;
168172
0 commit comments