pub struct DeflateReader<R> { /* private fields */ }Expand description
A raw-DEFLATE encoder that reads uncompressed bytes from a source.
A read returns the compressed form of the source bytes. End of file comes after the end of the stream.
If the caller of a DeflateSink does not flush, the sink and the reader
give the same bytes for one input and level. The reader
runs the compressor in the same sequence of steps, each into an empty
output buffer. The reader does not flush the stream before its end,
because a flush changes the bytes.
The reader holds one compressor, an input buffer of 64 KiB, and an output
buffer of 64 KiB. Its memory does not grow with the size of the source.
The reader returns the compressed bytes that it holds before it reads the
source again. reset starts a new stream in the
same compressor and buffers, so one reader can encode many objects in turn.
The reader implements AsyncBufRead. A caller that reads through
poll_fill_buf and consume takes the compressed bytes from the output
buffer with no copy.
Implementations§
Source§impl<R> DeflateReader<R>
impl<R> DeflateReader<R>
Sourcepub fn new(source: R, level: u8) -> DeflateReader<R>
pub fn new(source: R, level: u8) -> DeflateReader<R>
Creates a raw-DEFLATE encoder that reads from source at level.
level has the meaning that DeflateSink::new states.
Sourcepub fn reset(&mut self, source: R, level: u8) -> R
pub fn reset(&mut self, source: R, level: u8) -> R
Starts a new stream over source at level and returns the previous
source.
The reader resets the compressor in place with level and keeps the
buffers. The reader discards the source bytes and the compressed bytes
of the previous stream that it holds.
Sourcepub fn get_mut(&mut self) -> &mut R
pub fn get_mut(&mut self) -> &mut R
Returns a mutable reference to the source.
Bytes that a caller reads from the source through this reference do not reach the stream.
Sourcepub fn into_inner(self) -> R
pub fn into_inner(self) -> R
Returns the source.
The reader discards the source bytes and the compressed bytes that it holds.