pub struct DecompressContext { /* private fields */ }Expand description
Reusable decompression context that amortizes buffer allocations.
Holds internal buffers (output, Huffman/FSE workspace) across calls. Useful when decompressing many small frames in a loop.
let data = b"repeated decompression".repeat(100);
let compressed = zrip::compress(&data, 1).unwrap();
let mut ctx = zrip::DecompressContext::new();
for _ in 0..10 {
let output = ctx.decompress(&compressed).unwrap();
assert_eq!(&*output, &data[..]);
}Implementations§
Source§impl DecompressContext
impl DecompressContext
Sourcepub fn with_dict(dict: Dictionary) -> Self
pub fn with_dict(dict: Dictionary) -> Self
Creates a new context with a pre-loaded dictionary.
Sourcepub fn decompress(
&mut self,
input: &[u8],
) -> Result<Cow<'_, [u8]>, DecompressError>
pub fn decompress( &mut self, input: &[u8], ) -> Result<Cow<'_, [u8]>, DecompressError>
Decompresses input using DEFAULT_DECOMPRESS_LIMIT.
Sourcepub fn decompress_with_limit(
&mut self,
input: &[u8],
max_output: usize,
) -> Result<Cow<'_, [u8]>, DecompressError>
pub fn decompress_with_limit( &mut self, input: &[u8], max_output: usize, ) -> Result<Cow<'_, [u8]>, DecompressError>
Decompresses input with an explicit output size limit.
Returns DecompressError::OutputTooSmall if the decompressed output
would exceed max_output bytes.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DecompressContext
impl RefUnwindSafe for DecompressContext
impl Send for DecompressContext
impl Sync for DecompressContext
impl Unpin for DecompressContext
impl UnsafeUnpin for DecompressContext
impl UnwindSafe for DecompressContext
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