File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -279,6 +279,25 @@ impl Deflate {
279279 other => unreachable ! ( "set_dictionary does not return {other:?}" ) ,
280280 }
281281 }
282+
283+ /// Dynamically updates the compression level.
284+ ///
285+ /// This can be used to switch between compression levels for different
286+ /// kinds of data, or it can be used in conjunction with a call to [`Deflate::reset`]
287+ /// to reuse the compressor.
288+ ///
289+ /// This may return an error if there wasn't enough output space to complete
290+ /// the compression of the available input data before changing the
291+ /// compression level. Flushing the stream before calling this method
292+ /// ensures that the function will succeed on the first call.
293+ pub fn set_level ( & mut self , level : i32 ) -> Result < Status , DeflateError > {
294+ match crate :: deflate:: params ( & mut self . 0 , level, Default :: default ( ) ) {
295+ ReturnCode :: Ok => Ok ( Status :: Ok ) ,
296+ ReturnCode :: StreamError => Err ( DeflateError :: StreamError ) ,
297+ ReturnCode :: BufError => Ok ( Status :: BufError ) ,
298+ other => unreachable ! ( "set_level does not return {other:?}" ) ,
299+ }
300+ }
282301}
283302
284303impl Drop for Deflate {
You can’t perform that action at this time.
0 commit comments