Struct BzEncoder
pub struct BzEncoder<R> { /* private fields */ }
A compression stream which wraps an uncompressed stream of data. Compressed data will be read from the stream.
Implementations
impl<R: Read> BzEncoder<R>
fn new(r: R, level: Compression) -> SelfCreate a new compression stream which will compress at the given level to read compress output to the give output stream.
fn get_ref(&self) -> &RAcquires a reference to the underlying stream
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) -> RUnwrap the underlying writer, finishing the compression stream.
fn total_out(&self) -> u64Returns 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) -> u64Returns the number of bytes consumed by the compressor (e.g. the number of bytes read from the underlying stream)
Trait Implementations
impl<R: Read> Read for BzEncoder<R>
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
impl<W: Write + Read> 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
BzEncoder<BufReader<R>>: Freeze,
impl<R> RefUnwindSafe for BzEncoder<R>
where
BzEncoder<BufReader<R>>: RefUnwindSafe,
impl<R> Send for BzEncoder<R>
where
BzEncoder<BufReader<R>>: Send,
impl<R> Sync for BzEncoder<R>
where
BzEncoder<BufReader<R>>: Sync,
impl<R> Unpin for BzEncoder<R>
where
BzEncoder<BufReader<R>>: Unpin,
impl<R> UnsafeUnpin for BzEncoder<R>
where
BzEncoder<BufReader<R>>: UnsafeUnpin,
impl<R> UnwindSafe for BzEncoder<R>
where
BzEncoder<BufReader<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) -> TReturns the argument unchanged.
impl<T, U> Into<U> for BzEncoder<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 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>