pub struct Compressor { /* private fields */ }Expand description
A reusable block compressor that owns its dictionary.
This is the ergonomic API for use with alloc. For a no-alloc variant that
borrows the dictionary, see CompressorRef.
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.
The dictionary is cloned into owned storage.
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§
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