Struct DeflateEncoder
pub struct DeflateEncoder<R> { /* private fields */ }
A DEFLATE encoder, or compressor.
This structure implements a Read interface. When read from, it reads
uncompressed data from the underlying BufRead and provides the compressed data.
Examples
use *;
use io;
use Compression;
use DeflateEncoder;
use File;
use BufReader;
#
#
// Opens sample file, compresses the contents and returns a Vector
Implementations
impl<R> DeflateEncoder<R>
fn reset(&mut self, r: R) -> RResets the state of this encoder entirely, swapping out the input stream for another.
This function will reset the internal state of this encoder and replace the input stream with the one provided, returning the previous input stream. Future data read from this encoder will be the compressed version of
r's data.fn get_ref(&self) -> &RAcquires a reference to the underlying reader
fn get_mut(&mut self) -> &mut RAcquires a mutable reference to the underlying stream
Note that mutation of the stream may result in surprising results if this encoder is continued to be used.
fn into_inner(self) -> RConsumes this encoder, returning the underlying reader.
fn total_in(&self) -> u64Returns the number of bytes that have been read into this compressor.
Note that not all bytes read from the underlying object may be accounted for, there may still be some active buffering.
fn total_out(&self) -> u64Returns the number of bytes that the compressor has produced.
Note that not all bytes may have been read yet, some may still be buffered.
impl<R: BufRead> DeflateEncoder<R>
fn new(r: R, level: Compression) -> DeflateEncoder<R>Creates a new encoder which will read uncompressed data from the given stream and emit the compressed stream.
Trait Implementations
impl<R: BufRead> Read for DeflateEncoder<R>
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
impl<R: Debug> Debug for DeflateEncoder<R>
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl<W: BufRead + Write> Write for DeflateEncoder<W>
fn write(&mut self, buf: &[u8]) -> Result<usize>fn flush(&mut self) -> Result<()>
Auto Trait Implementations
impl<R> !UnwindSafe for DeflateEncoder<R>
impl<R> Freeze for DeflateEncoder<R>
where
R: Freeze,
impl<R> RefUnwindSafe for DeflateEncoder<R>
where
R: RefUnwindSafe,
impl<R> Send for DeflateEncoder<R>
where
R: Send,
impl<R> Sync for DeflateEncoder<R>
where
R: Sync,
impl<R> Unpin for DeflateEncoder<R>
where
R: Unpin,
impl<R> UnsafeUnpin for DeflateEncoder<R>
where
R: UnsafeUnpin,
Blanket Implementations
impl<T> Any for DeflateEncoder<R>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for DeflateEncoder<R>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for DeflateEncoder<R>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> From<T> for DeflateEncoder<R>
fn from(t: T) -> TReturns the argument unchanged.
impl<T, U> Into<U> for DeflateEncoder<R>
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for DeflateEncoder<R>
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for DeflateEncoder<R>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>