Struct libdeflater::Compressor

source ·
pub struct Compressor { /* private fields */ }
Expand description

A libdeflate compressor that can compress arbitrary data into DEFLATE, zlib, or gzip formats.

Implementations§

source§

impl Compressor

source

pub fn new(lvl: CompressionLvl) -> Compressor

Returns a newly constructed Compressor that compresses data with the supplied CompressionLvl

source

pub fn deflate_compress_bound(&mut self, n_bytes: usize) -> usize

Returns the maximum number of bytes required to encode n_bytes as deflate data. This is a hard upper-bound that assumes the worst possible compression ratio (i.e. assumes the data cannot be compressed), format overhead, etc.

source

pub fn deflate_compress( &mut self, in_raw_data: &[u8], out_deflate_data: &mut [u8] ) -> Result<usize, CompressionError>

Compresses in_raw_data as deflate data, writing the data into out_deflate_data. Returns the number of bytes written into out_deflate_data.

source

pub fn zlib_compress_bound(&mut self, n_bytes: usize) -> usize

Returns the maximum number of bytes required to encode n_bytes as zlib data. This is a hard upper-bound that assumes the worst possible compression ratio (i.e. assumes the data cannot be compressed), format overhead, etc.

source

pub fn zlib_compress( &mut self, in_raw_data: &[u8], out_zlib_data: &mut [u8] ) -> Result<usize, CompressionError>

Compresses in_raw_data as zlib data, writing the data into out_zlib_data. Returns the number of bytes written into out_zlib_data.

source

pub fn gzip_compress_bound(&mut self, n_bytes: usize) -> usize

Returns the maximum number of bytes required to encode n_bytes as gzip data. This is a hard upper-bound that assumes the worst possible compression ratio (i.e. assumes the data cannot be compressed), format overhead, etc.

source

pub fn gzip_compress( &mut self, in_raw_data: &[u8], out_gzip_data: &mut [u8] ) -> Result<usize, CompressionError>

Compresses in_raw_data as gzip data, writing the data into out_gzip_data. Returns the number of bytes written into out_gzip_data.

Trait Implementations§

source§

impl Drop for Compressor

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl Send for Compressor

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.