Struct Writer

struct Writer<W, D> { ... }

Implements the Write API around an Operation.

This can be used to wrap a raw in-memory operation in a write-focused API.

It can be used with either compression or decompression, and forwards the output to a wrapped Write.

Implementations

impl<W, D> Writer<W, D>

fn new(writer: W, operation: D) -> Self

Creates a new Writer with a fixed buffer capacity of 32KB

All output from the given operation will be forwarded to writer.

fn new_with_capacity(writer: W, operation: D, capacity: usize) -> Self

Creates a new Writer with user defined capacity.

All output from the given operation will be forwarded to writer.

fn with_output_buffer(output_buffer: Vec<u8>, writer: W, operation: D) -> Self

Creates a new Writer using the given output buffer.

The output buffer must have pre-allocated capacity (its capacity will not be changed after).

Usually you would use Vec::with_capacity(desired_buffer_size).

fn finish(self: &mut Self) -> Result<()>

Ends the stream.

This must be called after all data has been written to finish the stream.

If you forget to call this and just drop the Writer, you will have an incomplete output.

Keep calling it until it returns Ok(()), then don't call it again.

fn into_inner(self: Self) -> (W, D)

Return the wrapped Writer and Operation.

Careful: if you call this before calling [Writer::finish()], the output may be incomplete.

fn writer(self: &Self) -> &W

Gives a reference to the inner writer.

fn writer_mut(self: &mut Self) -> &mut W

Gives a mutable reference to the inner writer.

fn operation(self: &Self) -> &D

Gives a reference to the inner operation.

fn operation_mut(self: &mut Self) -> &mut D

Gives a mutable reference to the inner operation.

impl<T> Any for Writer<W, D>

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for Writer<W, D>

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for Writer<W, D>

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

impl<T> From for Writer<W, D>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T, U> Into for Writer<W, D>

fn into(self: 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 for Writer<W, D>

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for Writer<W, D>

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

impl<W, D> Freeze for Writer<W, D>

impl<W, D> RefUnwindSafe for Writer<W, D>

impl<W, D> Send for Writer<W, D>

impl<W, D> Sync for Writer<W, D>

impl<W, D> Unpin for Writer<W, D>

impl<W, D> UnsafeUnpin for Writer<W, D>

impl<W, D> UnwindSafe for Writer<W, D>

impl<W, D> Write for Writer<W, D>

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