Struct BzEncoder

pub struct BzEncoder<R> { /* private fields */ }

A bz2 encoder, or compressor.

This structure implements a BufRead interface and will read uncompressed data from an underlying stream and emit a stream of compressed data.

Implementations

impl<R> BzEncoder<R>

fn get_ref(&self) -> &R

Acquires a reference to the underlying stream

fn get_mut(&mut self) -> &mut R

Acquires 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) -> R

Consumes this encoder, returning the underlying reader.

fn total_out(&self) -> u64

Returns the number of bytes produced by the compressor (e.g. the number of bytes read from this stream)

Note that, due to buffering, this only bears any relation to total_in() when the compressor chooses to flush its data (unfortunately, this won't happen in general at the end of the stream, because the compressor doesn't know if there's more data to come). At that point, total_out() / total_in() would be the compression ratio.

fn total_in(&self) -> u64

Returns the number of bytes consumed by the compressor (e.g. the number of bytes read from the underlying stream)

impl<R: BufRead> BzEncoder<R>

fn new(r: R, level: Compression) -> Self

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 BzEncoder<R>

fn read(&mut self, buf: &mut [u8]) -> Result<usize>

impl<W: Write> Write for BzEncoder<W>

fn write(&mut self, buf: &[u8]) -> Result<usize>
fn flush(&mut self) -> Result<()>

Auto Trait Implementations

impl<R> Freeze for BzEncoder<R> where R: Freeze,

impl<R> RefUnwindSafe for BzEncoder<R> where R: RefUnwindSafe,

impl<R> Send for BzEncoder<R> where R: Send,

impl<R> Sync for BzEncoder<R> where R: Sync,

impl<R> Unpin for BzEncoder<R> where R: Unpin,

impl<R> UnsafeUnpin for BzEncoder<R> where R: UnsafeUnpin,

impl<R> UnwindSafe for BzEncoder<R> where R: UnwindSafe,

Blanket Implementations

impl<T> Any for BzEncoder<R> where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for BzEncoder<R> where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for BzEncoder<R> where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> From<T> for BzEncoder<R>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T, U> Into<U> for BzEncoder<R> where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom<U> for BzEncoder<R> where U: Into<T>,

type Error = never;
fn try_from(value: U) -> Result<T, never>

impl<T, U> TryInto<U> for BzEncoder<R> where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>