pub struct CompressorN<const N: usize = DEFAULT_NODICT_ENTRIES> { /* private fields */ }Expand description
A reusable no-dict block compressor (owning) with N hash-table entries.
Compressor is the standard-sized alias (8 KB table). Use this generic
form to pick a smaller table, e.g. CompressorN::<512>::new() for a 2 KB
table. N must be a power of two (checked at compile time).
This is the ergonomic owning API for use with alloc. For a no-alloc
variant, see CompressorRef. For a dictionary-seeded
compressor, see DictCompressor.
For one-shot compression, use compress or
compress_into instead.
§Example
use lz4rip_encode::{Compressor, get_maximum_output_size};
let mut comp = Compressor::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> CompressorN<N>
impl<const N: usize> CompressorN<N>
Sourcepub fn compress_into(
&mut self,
input: &[u8],
output: &mut [u8],
) -> Result<usize, CompressError>
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.
Trait Implementations§
Source§impl<const N: usize> Debug for CompressorN<N>
impl<const N: usize> Debug for CompressorN<N>
Source§impl<const N: usize> Default for CompressorN<N>
impl<const N: usize> Default for CompressorN<N>
Source§fn default() -> CompressorN<N>
fn default() -> CompressorN<N>
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl<const N: usize> Freeze for CompressorN<N>
impl<const N: usize> RefUnwindSafe for CompressorN<N>
impl<const N: usize> Send for CompressorN<N>
impl<const N: usize> Sync for CompressorN<N>
impl<const N: usize> Unpin for CompressorN<N>
impl<const N: usize> UnsafeUnpin for CompressorN<N>
impl<const N: usize> UnwindSafe for CompressorN<N>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more