pub struct Writer<W, D> { /* private fields */ }Expand description
Implementations§
Source§impl<W, D> Writer<W, D>
impl<W, D> Writer<W, D>
Sourcepub fn new(writer: W, operation: D) -> Self
pub 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.
Sourcepub fn new_with_capacity(writer: W, operation: D, capacity: usize) -> Self
pub 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.
Sourcepub fn with_output_buffer(
output_buffer: Vec<u8>,
writer: W,
operation: D,
) -> Self
pub 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).
Sourcepub fn finish(&mut self) -> Result<()>
pub fn finish(&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.
Sourcepub fn into_inner(self) -> (W, D)
pub fn into_inner(self) -> (W, D)
Return the wrapped Writer and Operation.
Careful: if you call this before calling Writer::finish(), the
output may be incomplete.
Sourcepub fn writer_mut(&mut self) -> &mut W
pub fn writer_mut(&mut self) -> &mut W
Gives a mutable reference to the inner writer.
Sourcepub fn operation_mut(&mut self) -> &mut D
pub fn operation_mut(&mut self) -> &mut D
Gives a mutable reference to the inner operation.
Trait Implementations§
Source§impl<W, D> Write for Writer<W, D>
impl<W, D> Write for Writer<W, D>
Source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
Source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector)1.0.0 · Source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
Source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
write_all_vectored)