Skip to main content

CompressorRefN

Struct CompressorRefN 

Source
pub struct CompressorRefN<const N: usize = DEFAULT_NODICT_ENTRIES> { /* private fields */ }
Expand description

A reusable no-dict block compressor with N hash-table entries.

CompressorRef is the standard-sized alias (8 KB table). Use this generic form to pick a smaller table for memory-constrained (e.g. embedded) targets, e.g. CompressorRefN::<512>::new() for a 2 KB table. N must be a power of two (checked at compile time).

This is the no-alloc API. With alloc, use Compressor instead. For one-shot compression, use compress_into instead.

§Example

use lz4rip_encode::{CompressorRef, get_maximum_output_size};

let mut comp = CompressorRef::new();
let input = b"hello world, hello world, hello!";
let mut output = vec![0u8; get_maximum_output_size(input.len())];
let compressed_len = comp.compress_into(input, &mut output).unwrap();

Implementations§

Source§

impl<const N: usize> CompressorRefN<N>

Source

pub fn new() -> Self

Create a new compressor without a dictionary.

Source

pub fn compress_into( &mut self, input: &[u8], output: &mut [u8], ) -> Result<usize, CompressError>

Compress input into output, returning the number of compressed bytes.

output must be at least get_maximum_output_size(input.len()) bytes.

Source

pub fn compress(&mut self, input: &[u8]) -> Vec<u8>

Compress input into a new Vec<u8>.

Trait Implementations§

Source§

impl<const N: usize> Debug for CompressorRefN<N>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<const N: usize> Default for CompressorRefN<N>

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<const N: usize> Freeze for CompressorRefN<N>

§

impl<const N: usize> RefUnwindSafe for CompressorRefN<N>

§

impl<const N: usize> Send for CompressorRefN<N>

§

impl<const N: usize> Sync for CompressorRefN<N>

§

impl<const N: usize> Unpin for CompressorRefN<N>

§

impl<const N: usize> UnsafeUnpin for CompressorRefN<N>

§

impl<const N: usize> UnwindSafe for CompressorRefN<N>

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.