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
impl Decompressor
Sourcepub fn with_dictionary(dict: Dictionary) -> Self
pub fn with_dictionary(dict: Dictionary) -> Self
A decompressor that uses dict for every frame.
Sourcepub fn set_dictionary(&mut self, dict: Option<Dictionary>)
pub fn set_dictionary(&mut self, dict: Option<Dictionary>)
Replaces (or removes) the dictionary.
Sourcepub fn decompress_append(
&mut self,
src: &[u8],
dst: &mut Vec<u8>,
) -> Result<(), Error>
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.
Sourcepub fn decompress_to_slice(
&mut self,
src: &[u8],
dst: &mut [u8],
) -> Result<usize, Error>
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
impl Debug for Decompressor
Auto Trait Implementations§
impl Forget for Decompressor
impl Freeze for Decompressorwhere
*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
impl Sync for Decompressor
impl Unpin for Decompressor
impl UnsafeUnpin for Decompressorwhere
*const BlockDecoder is !null: UnsafeUnpin,
PhantomData<BlockDecoder>: UnsafeUnpin,
*const ArcInner<Inner> is !null: UnsafeUnpin,
PhantomData<ArcInner<Inner>>: UnsafeUnpin,
impl UnwindSafe for Decompressor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more