pub struct StreamEncoder { /* private fields */ }Expand description
Flate (zlib) stream encoder.
The encoder keeps the underlying flate2::Compress state across calls and
resets it per stream, so a single instance can compress many small streams
(one per content stream, for instance) without paying the zlib state
initialisation cost every time. This is roughly 4-6x faster than creating a
fresh encoder per stream on typical tiny PDF content streams.
Implementations§
Source§impl StreamEncoder
impl StreamEncoder
pub fn new() -> Self
pub fn encode( &mut self, data: &[u8], filter: StreamFilter, ) -> PdfResult<Vec<u8>>
Sourcepub fn encode_with_compression(
&mut self,
data: &[u8],
filter: StreamFilter,
level: u32,
) -> PdfResult<Vec<u8>>
pub fn encode_with_compression( &mut self, data: &[u8], filter: StreamFilter, level: u32, ) -> PdfResult<Vec<u8>>
Like StreamEncoder::encode but with an explicit zlib level (0-9)
for the flate filter; other filters ignore the level.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for StreamEncoder
impl RefUnwindSafe for StreamEncoder
impl Send for StreamEncoder
impl Sync for StreamEncoder
impl Unpin for StreamEncoder
impl UnsafeUnpin for StreamEncoder
impl UnwindSafe for StreamEncoder
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