Struct reth_nippy_jar::compression::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>

pub fn new() -> Result<Decompressor<'static>, Error>

Creates a new zstd decompressor.

pub fn with_dictionary( dictionary: &[u8], ) -> Result<Decompressor<'static>, Error>

Creates a new zstd decompressor, using the given dictionary.

§

impl<'a> Decompressor<'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>

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,

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,

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>

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>

Sets a decompression parameter for this decompressor.

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.

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>

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>

§

fn default() -> Decompressor<'a>

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

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

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more

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