Skip to main content

CompressTable

Enum CompressTable 

Source
pub enum CompressTable {
    Small(HashTable4KU16),
    Large(HashTable4K),
}
Expand description

A reusable compression table that avoids re-allocating the internal hash table on every call.

This is useful when compressing many small inputs in a loop. Create one table and pass it to compress_into_with_table repeatedly.

§Example

use lz4_flex::block::{compress_into_with_table, get_maximum_output_size, CompressTable};

let mut table = CompressTable::default();
let input = b"hello world, hello world, hello!";
let mut output = vec![0u8; get_maximum_output_size(input.len())];
let compressed_len = compress_into_with_table(input, &mut output, &mut table).unwrap();

Variants§

§

Small(HashTable4KU16)

Table using 16-bit entries, suitable for inputs where input.len() < u16::MAX.

§

Large(HashTable4K)

Table using 32-bit entries, suitable for any input size.

Implementations§

Source§

impl CompressTable

Source

pub fn small() -> Self

Create a small table (16-bit entries). More memory efficient, but only usable when the total input size is less than 65535 bytes.

Source

pub fn large() -> Self

Create a large table (32-bit entries). Works for any input size.

Trait Implementations§

Source§

impl Default for CompressTable

Source§

fn default() -> Self

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

Auto Trait Implementations§

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.

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.