Struct bzip2::raw::Stream
[−]
[src]
pub struct Stream { // some fields omitted }
Wrapper around a raw instance of bz_stream
.
Methods
impl Stream
[src]
fn new_decompress(small: bool) -> Stream
Creates a new stream prepared for decompression.
If small
is true, then the library will use an alternative
decompression algorithm which uses less memory but at the cost of
decompressing more slowly (roughly speaking, half the speed, but the
maximum memory requirement drops to around 2300k). See
fn new_compress(lvl: Compress, work_factor: u32) -> Stream
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.
fn decompress(&mut self, input: &[u8], output: &mut [u8]) -> c_int
Decompress a block of input into a block of output.
fn decompress_vec(&mut self, input: &[u8], output: &mut Vec<u8>) -> c_int
Decompress a block of input into an output vector.
This function will not grow output
, but it will fill the space after
its current length up to its capacity. The length of the vector will be
adjusted appropriately.
fn compress(&mut self, input: &[u8], output: &mut [u8], action: Action) -> c_int
Compress a block of input into a block of output.
If anything other than BZ_OK is seen, Err
is returned. The action
given must be one of Run, Flush or Finish.
fn compress_vec(&mut self, input: &[u8], output: &mut Vec<u8>, action: Action) -> c_int
Compress a block of input into an output vector.
This function will not grow output
, but it will fill the space after
its current length up to its capacity. The length of the vector will be
adjusted appropriately.
fn total_in(&self) -> u64
Total number of bytes processed as input
fn total_out(&self) -> u64
Total number of bytes processed as output