Struct buf_redux::LineWriter
source · pub struct LineWriter<W: Write>(_);
Expand description
A drop-in replacement for std::io::LineWriter
with more functionality.
This is, in fact, only a thin wrapper around
BufWriter
<W,
policy::FlushOnNewline
>
, which
demonstrates the power of custom WriterPolicy
implementations.
Implementations
sourceimpl<W: Write> LineWriter<W>
impl<W: Write> LineWriter<W>
sourcepub fn with_capacity(cap: usize, inner: W) -> Self
pub fn with_capacity(cap: usize, inner: W) -> Self
Wrap inner
with the given buffer capacity.
sourcepub fn new_ringbuf(inner: W) -> Self
pub fn new_ringbuf(inner: W) -> Self
Wrap inner
with the default buffer capacity using a ringbuffer.
sourcepub fn with_capacity_ringbuf(cap: usize, inner: W) -> Self
pub fn with_capacity_ringbuf(cap: usize, inner: W) -> Self
Wrap inner
with the given buffer capacity using a ringbuffer.
sourcepub fn with_buffer(buf: Buffer, inner: W) -> LineWriter<W>ⓘNotable traits for LineWriter<W>impl<W: Write> Write for LineWriter<W>
pub fn with_buffer(buf: Buffer, inner: W) -> LineWriter<W>ⓘNotable traits for LineWriter<W>impl<W: Write> Write for LineWriter<W>
Wrap inner
with an existing Buffer
instance.
Note
Does not clear the buffer first! If there is data already in the buffer it will be written out on the next flush!
sourcepub fn get_mut(&mut self) -> &mut W
pub fn get_mut(&mut self) -> &mut W
Get a mutable reference to the inner writer.
Note
If the buffer has not been flushed, writing directly to the inner type will cause data inconsistency.
sourcepub fn reserve(&mut self, additional: usize)
pub fn reserve(&mut self, additional: usize)
Ensure enough space in the buffer for at least additional
bytes. May not be
quite exact due to implementation details of the buffer’s allocator.
sourcepub fn into_inner(self) -> Result<W, IntoInnerError<Self>>
pub fn into_inner(self) -> Result<W, IntoInnerError<Self>>
Flush the buffer and unwrap, returning the inner writer on success,
or a type wrapping self
plus the error otherwise.
sourcepub fn into_inner_with_err(self) -> (W, Option<Error>)
pub fn into_inner_with_err(self) -> (W, Option<Error>)
Flush the buffer and unwrap, returning the inner writer and any error encountered during flushing.
sourcepub fn into_inner_with_buf(self) -> (W, Buffer)
pub fn into_inner_with_buf(self) -> (W, Buffer)
Consume self
and return both the underlying writer and the buffer.
Trait Implementations
sourceimpl<W: Write + Debug> Debug for LineWriter<W>
impl<W: Write + Debug> Debug for LineWriter<W>
sourceimpl<W: Write> Write for LineWriter<W>
impl<W: Write> Write for LineWriter<W>
sourcefn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
sourcefn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
sourcefn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector
)1.0.0 · sourcefn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
sourcefn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
write_all_vectored
)