pub struct BzEncoder { /* private fields */ }
bzip2
only.Implementations§
Source§impl BzEncoder
impl BzEncoder
Sourcepub fn new(params: Bzip2EncoderParams, work_factor: u32) -> Self
pub fn new(params: Bzip2EncoderParams, work_factor: u32) -> Self
Creates a new stream prepared for compression.
The work_factor
parameter controls how the compression phase behaves
when presented with worst case, highly repetitive, input data. If
compression runs into difficulties caused by repetitive data, the
library switches from the standard sorting algorithm to a fallback
algorithm. The fallback is slower than the standard algorithm by perhaps
a factor of three, but always behaves reasonably, no matter how bad the
input.
Lower values of work_factor
reduce the amount of effort the standard
algorithm will expend before resorting to the fallback. You should set
this parameter carefully; too low, and many inputs will be handled by
the fallback algorithm and so compress rather slowly, too high, and your
average-to-worst case compression times can become very large. The
default value of 30 gives reasonable behaviour over a wide range of
circumstances.
Allowable values range from 0 to 250 inclusive. 0 is a special case, equivalent to using the default value of 30.