pub type DStream<'a> = DCtx<'a>;
Expand description
A Decompression stream.
Same as DCtx
.
Aliased Type§
struct DStream<'a>(/* private fields */);
Implementations§
source§impl<'a> DCtx<'a>
impl<'a> DCtx<'a>
sourcepub fn try_create() -> Option<Self>
pub fn try_create() -> Option<Self>
Try to create a new decompression context.
Returns None
if the operation failed (for example, not enough memory).
sourcepub fn decompress<C: WriteBuf + ?Sized>(
&mut self,
dst: &mut C,
src: &[u8]
) -> SafeResult
pub fn decompress<C: WriteBuf + ?Sized>( &mut self, dst: &mut C, src: &[u8] ) -> SafeResult
Fully decompress the given frame.
This decompress an entire frame in-memory. If you can have enough memory to store both the input and output buffer, then it may be faster that streaming decompression.
Wraps the ZSTD_decompressDCtx()
function.
sourcepub fn decompress_using_dict<C: WriteBuf + ?Sized>(
&mut self,
dst: &mut C,
src: &[u8],
dict: &[u8]
) -> SafeResult
pub fn decompress_using_dict<C: WriteBuf + ?Sized>( &mut self, dst: &mut C, src: &[u8], dict: &[u8] ) -> SafeResult
Fully decompress the given frame using a dictionary.
Dictionary must be identical to the one used during compression.
If you plan on using the same dictionary multiple times, it is faster to create a DDict
first and use decompress_using_ddict
.
Wraps ZSTD_decompress_usingDict
sourcepub fn decompress_using_ddict<C: WriteBuf + ?Sized>(
&mut self,
dst: &mut C,
src: &[u8],
ddict: &DDict<'_>
) -> SafeResult
pub fn decompress_using_ddict<C: WriteBuf + ?Sized>( &mut self, dst: &mut C, src: &[u8], ddict: &DDict<'_> ) -> SafeResult
Fully decompress the given frame using a dictionary.
Dictionary must be identical to the one used during compression.
Wraps the ZSTD_decompress_usingDDict()
function.
sourcepub fn init(&mut self) -> SafeResult
pub fn init(&mut self) -> SafeResult
Initializes an existing DStream
for decompression.
This is equivalent to calling:
reset(SessionOnly)
disable_dictionary()
Wraps the ZSTD_initCStream()
function.
sourcepub fn reset(&mut self, reset: ResetDirective) -> SafeResult
pub fn reset(&mut self, reset: ResetDirective) -> SafeResult
Resets the state of the context.
Depending on the reset mode, it can reset the session, the parameters, or both.
Wraps the ZSTD_DCtx_reset()
function.
sourcepub fn load_dictionary(&mut self, dict: &[u8]) -> SafeResult
pub fn load_dictionary(&mut self, dict: &[u8]) -> SafeResult
Loads a dictionary.
This will let this context decompress frames that were compressed using this dictionary.
The dictionary content will be copied internally and does not need to be kept alive after calling this function.
If you need to use the same dictionary for multiple contexts, it may be more efficient to
create a DDict
first, then loads that.
The dictionary will apply to all future frames, until a new dictionary is set.
sourcepub fn disable_dictionary(&mut self) -> SafeResult
pub fn disable_dictionary(&mut self) -> SafeResult
Return to “no-dictionary” mode.
This will disable any dictionary/prefix previously registered for future frames.
sourcepub fn ref_ddict<'b>(&mut self, ddict: &DDict<'b>) -> SafeResultwhere
'b: 'a,
pub fn ref_ddict<'b>(&mut self, ddict: &DDict<'b>) -> SafeResultwhere 'b: 'a,
References a dictionary.
This will let this context decompress frames compressed with the same dictionary.
It will apply to all frames decompressed by this context (until a new dictionary is set).
Wraps the ZSTD_DCtx_refDDict()
function.
sourcepub fn ref_prefix<'b>(&mut self, prefix: &'b [u8]) -> SafeResultwhere
'b: 'a,
pub fn ref_prefix<'b>(&mut self, prefix: &'b [u8]) -> SafeResultwhere 'b: 'a,
Use some prefix as single-use dictionary for the next frame.
Just like a dictionary, this only works if compression was done with the same prefix.
But unlike a dictionary, this only applies to the next frame.
Wraps the ZSTD_DCtx_refPrefix()
function.
sourcepub fn set_parameter(&mut self, param: DParameter) -> SafeResult
pub fn set_parameter(&mut self, param: DParameter) -> SafeResult
Sets a decompression parameter.
sourcepub fn decompress_stream<C: WriteBuf + ?Sized>(
&mut self,
output: &mut OutBuffer<'_, C>,
input: &mut InBuffer<'_>
) -> SafeResult
pub fn decompress_stream<C: WriteBuf + ?Sized>( &mut self, output: &mut OutBuffer<'_, C>, input: &mut InBuffer<'_> ) -> SafeResult
Performs a step of a streaming decompression operation.
This will read some data from input
and/or write some data to output
.
Returns
Ok(0)
if the current frame just finished decompressing successfully.Ok(hint)
with a hint for the “ideal” amount of input data to provide in the next call. Can be safely ignored.
Wraps the ZSTD_decompressStream()
function.
sourcepub fn in_size() -> usize
pub fn in_size() -> usize
Wraps the ZSTD_DStreamInSize()
function.
Returns a hint for the recommended size of the input buffer for decompression.