Struct BzEncoder
pub struct BzEncoder<W: Write> { /* private fields */ }
A compression stream which will have uncompressed data written to it and will write compressed data to an output stream.
Implementations
impl<W: Write> BzEncoder<W>
fn new(obj: W, level: Compression) -> SelfCreate a new compression stream which will compress at the given level to write compress output to the give output stream.
fn get_ref(&self) -> &WAcquires a reference to the underlying writer.
fn get_mut(&mut self) -> &mut WAcquires a mutable reference to the underlying writer.
Note that mutating the output/input state of the stream may corrupt this object, so care must be taken when using this method.
fn try_finish(&mut self) -> Result<()>Attempt to finish this output stream, writing out final chunks of data.
Note that this function can only be used once data has finished being written to the output stream. After this function is called then further calls to
writemay result in a panic.Panics
Attempts to write data to this stream may result in a panic after this function is called.
fn finish(self) -> Result<W>Consumes this encoder, flushing the output stream.
This will flush the underlying data stream and then return the contained writer if the flush succeeded.
Note that this function may not be suitable to call in a situation where the underlying stream is an asynchronous I/O stream. To finish a stream the
try_finish(orshutdown) method should be used instead. To re-acquire ownership of a stream it is safe to call this method aftertry_finishorshutdownhas returnedOk.fn total_out(&self) -> u64Returns the number of bytes produced by the compressor
Note that, due to buffering, this only bears any relation to
total_inafter a call toflush. At that point,total_out() / total_in()is the compression ratio.fn total_in(&self) -> u64Returns the number of bytes consumed by the compressor (e.g. the number of bytes written to this stream.)
Trait Implementations
impl<W: Write> Drop for BzEncoder<W>
fn drop(&mut self)
impl<W: Write> Write for BzEncoder<W>
fn write(&mut self, data: &[u8]) -> Result<usize>fn flush(&mut self) -> Result<()>
Auto Trait Implementations
impl<W> Freeze for BzEncoder<W>
where
Option<W>: Freeze,
impl<W> RefUnwindSafe for BzEncoder<W>
where
Option<W>: RefUnwindSafe,
impl<W> Send for BzEncoder<W>
where
Option<W>: Send,
impl<W> Sync for BzEncoder<W>
where
Option<W>: Sync,
impl<W> Unpin for BzEncoder<W>
where
Option<W>: Unpin,
impl<W> UnsafeUnpin for BzEncoder<W>
where
Option<W>: UnsafeUnpin,
impl<W> UnwindSafe for BzEncoder<W>
where
Option<W>: UnwindSafe,
Blanket Implementations
impl<T> Any for BzEncoder<W>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for BzEncoder<W>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for BzEncoder<W>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> From<T> for BzEncoder<W>
fn from(t: T) -> TReturns the argument unchanged.
impl<T, U> Into<U> for BzEncoder<W>
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<W>
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for BzEncoder<W>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>