Skip to main content

Decompressor

Struct Decompressor 

Source
pub struct Decompressor { /* private fields */ }
Expand description

A reusable decompressor (libzstd’s ZSTD_DCtx).

Keeps its tables and buffers between calls, so decompressing many small inputs doesn’t allocate each time, and optionally holds a Dictionary.

let mut d = zstd_native::Decompressor::new();
assert_eq!(d.decompress(compressed)?, b"hello");

Implementations§

Source§

impl Decompressor

Source

pub fn new() -> Self

A decompressor without a dictionary.

Source

pub fn with_dictionary(dict: Dictionary) -> Self

A decompressor that uses dict for every frame.

Source

pub fn set_dictionary(&mut self, dict: Option<Dictionary>)

Replaces (or removes) the dictionary.

Source

pub fn decompress(&mut self, src: &[u8]) -> Result<Vec<u8>, Error>

Decompresses every frame in src (concatenated frames and skippable frames are allowed) into a new vector.

§Errors

Any Error for corrupt, truncated or unsupported input.

Source

pub fn decompress_append( &mut self, src: &[u8], dst: &mut Vec<u8>, ) -> Result<(), Error>

Like decompress but appends to dst, reusing its capacity.

§Errors

Any Error for corrupt, truncated or unsupported input; dst then holds the data decoded before the error.

Source

pub fn decompress_to_slice( &mut self, src: &[u8], dst: &mut [u8], ) -> Result<usize, Error>

Decompresses every frame in src into dst, returning the decompressed size.

§Errors

Error::OutputTooSmall if dst can’t hold the result, or any other Error for corrupt, truncated or unsupported input.

Trait Implementations§

Source§

impl Debug for Decompressor

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Decompressor

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Forget for Decompressor

§

impl Freeze for Decompressor
where *const BlockDecoder is !null: Freeze, PhantomData<BlockDecoder>: Freeze, *const ArcInner<Inner> is !null: Freeze, PhantomData<ArcInner<Inner>>: Freeze,

§

impl Move for Decompressor

§

impl RefUnwindSafe for Decompressor

§

impl Send for Decompressor
where BoxRaw<BlockDecoder>: Send, Arc<Inner>: Send,

§

impl Sync for Decompressor
where BoxRaw<BlockDecoder>: Sync, Arc<Inner>: Sync,

§

impl Unpin for Decompressor
where Box<BlockDecoder>: Unpin, Arc<Inner>: Unpin,

§

impl UnsafeUnpin for Decompressor
where *const BlockDecoder is !null: UnsafeUnpin, PhantomData<BlockDecoder>: UnsafeUnpin, *const ArcInner<Inner> is !null: UnsafeUnpin, PhantomData<ArcInner<Inner>>: UnsafeUnpin,

§

impl UnwindSafe for Decompressor
where BoxRaw<BlockDecoder>: UnwindSafe, Arc<Inner>: UnwindSafe,

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>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.