pub struct Compressor { /* private fields */ }Expand description
Compresses stream after stream with the same tables, for writers of
many streams (PDF’s): each stream is the one compress_with writes,
without allocating and clearing the compressor’s 300 KiB of tables
anew for each.
use pltrs_codec::{zlib, CompressionLevel};
use pltrs_codec::deflate::Options;
let mut compressor = zlib::Compressor::new();
let options = Options::new(CompressionLevel::DEFAULT);
for text in [&b"first stream"[..], b"second, second"] {
let mut packed = Vec::new();
compressor.compress_into(text, options, &mut packed)?;
assert_eq!(packed, zlib::compress_with(text, options)?);
}Implementations§
Source§impl Compressor
impl Compressor
Sourcepub fn compress_into(
&mut self,
data: &[u8],
options: Options,
out: &mut Vec<u8>,
) -> Result<(), OutOfMemory>
pub fn compress_into( &mut self, data: &[u8], options: Options, out: &mut Vec<u8>, ) -> Result<(), OutOfMemory>
Appends the zlib stream of data with options to out.
§Errors
When the memory for the compressor or the output cannot be
allocated (what was written of the stream stays in out).
Trait Implementations§
Source§impl Debug for Compressor
impl Debug for Compressor
Auto Trait Implementations§
impl Forget for Compressor
impl Freeze for Compressor
impl Move 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