pub struct CompressorRef<'a> { /* private fields */ }Expand description
A reusable block compressor that borrows its dictionary.
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 CompressorRef<'static>
impl CompressorRef<'static>
Source§impl<'a> CompressorRef<'a>
impl<'a> CompressorRef<'a>
Sourcepub fn with_dict(dict: &'a [u8]) -> Self
pub fn with_dict(dict: &'a [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 CompressorRef<'_>
impl Debug for CompressorRef<'_>
Auto Trait Implementations§
impl<'a> Freeze for CompressorRef<'a>
impl<'a> RefUnwindSafe for CompressorRef<'a>
impl<'a> Send for CompressorRef<'a>
impl<'a> Sync for CompressorRef<'a>
impl<'a> Unpin for CompressorRef<'a>
impl<'a> UnsafeUnpin for CompressorRef<'a>
impl<'a> UnwindSafe for CompressorRef<'a>
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