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) -> SelfCreates a new
Writerwith a fixed buffer capacity of 32KBAll output from the given operation will be forwarded to
writer.fn new_with_capacity(writer: W, operation: D, capacity: usize) -> SelfCreates a new
Writerwith 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) -> SelfCreates a new
Writerusing 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
WriterandOperation.Careful: if you call this before calling [
Writer::finish()], the output may be incomplete.fn writer(self: &Self) -> &WGives a reference to the inner writer.
fn writer_mut(self: &mut Self) -> &mut WGives a mutable reference to the inner writer.
fn operation(self: &Self) -> &DGives a reference to the inner operation.
fn operation_mut(self: &mut Self) -> &mut DGives 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) -> TReturns the argument unchanged.
impl<T, U> Into for Writer<W, D>
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses 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<()>