pub struct Compressor { /* private fields */ }Expand description
A reusable block compressor. Pre-allocates the hash table once and reuses it across calls.
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 Compressor
impl Compressor
Sourcepub fn with_dict(dict: &[u8]) -> Self
pub fn with_dict(dict: &[u8]) -> Self
Create a new compressor seeded with an external dictionary.
If dict is shorter than 4 bytes, it is ignored.
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 Debug for Compressor
impl Debug for Compressor
Auto Trait Implementations§
impl Freeze for Compressor
impl RefUnwindSafe for Compressor
impl Send for Compressor
impl Sync for Compressor
impl Unpin for Compressor
impl UnsafeUnpin for Compressor
impl UnwindSafe for Compressor
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