Skip to main content

DecodeOptions

Struct DecodeOptions 

Source
pub struct DecodeOptions<'d> { /* private fields */ }
Expand description

Configurable decompression: an output-size limit, a maximum accepted window log, and an optional dictionary.

use libzstd_bitexact_rs::DecodeOptions;
let frame = [0x28, 0xB5, 0x2F, 0xFD, 0x20, 0x05, 0x2B, 0x00, 0x00, b'a'];
let out = DecodeOptions::new().limit(1 << 20).decompress(&frame).unwrap();
assert_eq!(out, b"aaaaa");

Implementations§

Source§

impl<'d> DecodeOptions<'d>

Source

pub fn new() -> Self

Default options: no output limit, window log up to WINDOW_LOG_MAX, no dictionary.

Source

pub fn limit(self, limit: usize) -> Self

Fail with Error::OutputTooLarge once the output would exceed limit bytes. Use this on untrusted input to defuse decompression bombs.

Source

pub fn window_log_max(self, window_log_max: u32) -> Self

Reject frames whose declared window log exceeds window_log_max (ZSTD_d_windowLogMax). Values above WINDOW_LOG_MAX are treated as WINDOW_LOG_MAX.

Source

pub fn dictionary(self, dictionary: &'d Dictionary) -> Self

Decode using dictionary as window history and entropy-table seed (ZSTD_decompress_usingDict). The dictionary applies to every frame in the input.

Source

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

Decompress a sequence of frames with these options.

Trait Implementations§

Source§

impl<'d> Clone for DecodeOptions<'d>

Source§

fn clone(&self) -> DecodeOptions<'d>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for DecodeOptions<'_>

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<'d> Freeze for DecodeOptions<'d>

§

impl<'d> RefUnwindSafe for DecodeOptions<'d>

§

impl<'d> Send for DecodeOptions<'d>

§

impl<'d> Sync for DecodeOptions<'d>

§

impl<'d> Unpin for DecodeOptions<'d>

§

impl<'d> UnsafeUnpin for DecodeOptions<'d>

§

impl<'d> UnwindSafe for DecodeOptions<'d>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.