[][src]Struct zstd::block::Compressor

pub struct Compressor { /* fields omitted */ }

Allows to compress independently multiple blocks of data.

This reduces memory usage compared to calling compress multiple times. The compressed blocks are still completely independent.

Methods

impl Compressor[src]

pub fn new() -> Self[src]

Creates a new zstd compressor

pub fn with_dict(dict: Vec<u8>) -> Self[src]

Creates a new zstd compressor, using the given dictionary.

pub fn compress_to_buffer(
    &mut self,
    source: &[u8],
    destination: &mut [u8],
    level: i32
) -> Result<usize>
[src]

Compress a single block of data to the given destination buffer.

Returns the number of bytes written, or an error if something happened (for instance if the destination buffer was too small).

A level of 0 uses zstd's default (currently 3).

pub fn compress(&mut self, data: &[u8], level: i32) -> Result<Vec<u8>>[src]

Compresses a block of data and returns the compressed result.

A level of 0 uses zstd's default (currently 3).

Trait Implementations

impl Default for Compressor[src]

Auto Trait Implementations

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]