Struct Compress
pub struct Compress { /* private fields */ }
Representation of an in-memory compression stream.
An instance of Compress can be used to compress a stream of bz2 data.
Implementations
impl Compress
fn new(lvl: Compression, work_factor: u32) -> SelfCreates a new stream prepared for compression.
The
work_factorparameter 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_factorreduce 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 compress(&mut self, input: &[u8], output: &mut [u8], action: Action) -> Result<Status, Error>Compress a block of input into a block of output.
If anything other than
BZ_OKis seen,Erris returned.The action given must be one of
Action::Run,Action::FlushorAction::Finish.fn compress_uninit(&mut self, input: &[u8], output: &mut [MaybeUninit<u8>], action: Action) -> Result<Status, Error>Same as
Self::compressbut accepts an uninitialisedoutputbuffer.fn compress_vec(&mut self, input: &[u8], output: &mut Vec<u8>, action: Action) -> Result<Status, Error>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) -> u64Total number of bytes processed as input
fn total_out(&self) -> u64Total number of bytes processed as output
Auto Trait Implementations
impl Freeze for Compress
impl RefUnwindSafe for Compress
impl Send for Compress
impl Sync for Compress
impl Unpin for Compress
impl UnsafeUnpin for Compress
impl UnwindSafe for Compress
Blanket Implementations
impl<T> Any for Compress
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for Compress
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for Compress
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> From<T> for Compress
fn from(t: T) -> TReturns the argument unchanged.
impl<T, U> Into<U> for Compress
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for Compress
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for Compress
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>