Struct Decompressor
pub struct Decompressor<'a> { /* private fields */ }
Expand description
Allows to decompress independently multiple blocks of data.
This reduces memory usage compared to calling decompress
multiple times.
Implementations§
§impl Decompressor<'static>
impl Decompressor<'static>
pub fn new() -> Result<Decompressor<'static>, Error>
pub fn new() -> Result<Decompressor<'static>, Error>
Creates a new zstd decompressor.
pub fn with_dictionary(
dictionary: &[u8],
) -> Result<Decompressor<'static>, Error>
pub fn with_dictionary( dictionary: &[u8], ) -> Result<Decompressor<'static>, Error>
Creates a new zstd decompressor, using the given dictionary.
§impl<'a> Decompressor<'a>
impl<'a> Decompressor<'a>
pub fn with_prepared_dictionary<'b>(
dictionary: &'a DecoderDictionary<'b>,
) -> Result<Decompressor<'a>, Error>where
'b: 'a,
pub fn with_prepared_dictionary<'b>(
dictionary: &'a DecoderDictionary<'b>,
) -> Result<Decompressor<'a>, Error>where
'b: 'a,
Creates a new decompressor using an existing DecoderDictionary
.
Note that using a dictionary means that compression will need to use the same dictionary.
pub fn set_dictionary(&mut self, dictionary: &[u8]) -> Result<(), Error>
pub fn set_dictionary(&mut self, dictionary: &[u8]) -> Result<(), Error>
Changes the dictionary used by this decompressor.
Will affect future compression jobs.
Note that using a dictionary means that compression will need to use the same dictionary.
pub fn set_prepared_dictionary<'b>(
&mut self,
dictionary: &'a DecoderDictionary<'b>,
) -> Result<(), Error>where
'b: 'a,
pub fn set_prepared_dictionary<'b>(
&mut self,
dictionary: &'a DecoderDictionary<'b>,
) -> Result<(), Error>where
'b: 'a,
Changes the dictionary used by this decompressor.
Note that using a dictionary means that compression will need to use the same dictionary.
pub fn decompress_to_buffer<C>(
&mut self,
source: &[u8],
destination: &mut C,
) -> Result<usize, Error>where
C: WriteBuf + ?Sized,
pub fn decompress_to_buffer<C>(
&mut self,
source: &[u8],
destination: &mut C,
) -> Result<usize, Error>where
C: WriteBuf + ?Sized,
Deompress 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).
pub fn decompress(
&mut self,
data: &[u8],
capacity: usize,
) -> Result<Vec<u8>, Error>
pub fn decompress( &mut self, data: &[u8], capacity: usize, ) -> Result<Vec<u8>, Error>
Decompress a block of data, and return the result in a Vec<u8>
.
The decompressed data should be at most capacity
bytes,
or an error will be returned.
pub fn set_parameter(&mut self, parameter: DParameter) -> Result<(), Error>
pub fn set_parameter(&mut self, parameter: DParameter) -> Result<(), Error>
Sets a decompression parameter for this decompressor.
pub fn window_log_max(&mut self, log_distance: u32) -> Result<(), Error>
pub fn window_log_max(&mut self, log_distance: u32) -> Result<(), Error>
Sets the maximum back-reference distance.
The actual maximum distance is going to be 2^log_distance
.
This will need to at least match the value set when compressing.
pub fn include_magicbytes(
&mut self,
include_magicbytes: bool,
) -> Result<(), Error>
Available on crate feature experimental
only.
pub fn include_magicbytes( &mut self, include_magicbytes: bool, ) -> Result<(), Error>
experimental
only.Enables or disabled expecting the 4-byte magic header
Only available with the experimental
feature.
This will need to match the settings used when compressing.
pub fn upper_bound(_data: &[u8]) -> Option<usize>
pub fn upper_bound(_data: &[u8]) -> Option<usize>
Get an upper bound on the decompressed size of data, if available
This can be used to pre-allocate enough capacity for decompress_to_buffer
and is used by decompress
to ensure that it does not over-allocate if
you supply a large capacity
.
Will return None
if the upper bound cannot be determined or is larger than usize::MAX
Note that unless the experimental
feature is enabled, this will always return None
.
Trait Implementations§
§impl<'a> Default for Decompressor<'a>
impl<'a> Default for Decompressor<'a>
§fn default() -> Decompressor<'a>
fn default() -> Decompressor<'a>
Auto Trait Implementations§
impl<'a> Freeze for Decompressor<'a>
impl<'a> RefUnwindSafe for Decompressor<'a>
impl<'a> Send for Decompressor<'a>
impl<'a> Sync for Decompressor<'a>
impl<'a> Unpin for Decompressor<'a>
impl<'a> UnwindSafe for Decompressor<'a>
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 8 bytes