Struct buf_redux::LineWriter [−][src]
pub struct LineWriter<W: Write>(_);
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.
Methods
impl<W: Write> LineWriter<W>
[src]
impl<W: Write> LineWriter<W>
pub fn new(inner: W) -> Self
[src]
pub fn new(inner: W) -> Self
Wrap inner
with the default buffer capacity.
pub fn with_capacity(cap: usize, inner: W) -> Self
[src]
pub fn with_capacity(cap: usize, inner: W) -> Self
Wrap inner
with the given buffer capacity.
pub fn new_ringbuf(inner: W) -> Self
[src]
pub fn new_ringbuf(inner: W) -> Self
Wrap inner
with the default buffer capacity using a ringbuffer.
pub fn with_capacity_ringbuf(cap: usize, inner: W) -> Self
[src]
pub fn with_capacity_ringbuf(cap: usize, inner: W) -> Self
Wrap inner
with the given buffer capacity using a ringbuffer.
ⓘImportant traits for LineWriter<W>pub fn with_buffer(buf: Buffer, inner: W) -> LineWriter<W>
[src]
pub fn with_buffer(buf: Buffer, inner: W) -> 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!
pub fn get_ref(&self) -> &W
[src]
pub fn get_ref(&self) -> &W
Get a reference to the inner writer.
pub fn get_mut(&mut self) -> &mut W
[src]
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.
pub fn capacity(&self) -> usize
[src]
pub fn capacity(&self) -> usize
Get the capacity of the inner buffer.
pub fn buf_len(&self) -> usize
[src]
pub fn buf_len(&self) -> usize
Get the number of bytes currently in the buffer.
pub fn reserve(&mut self, additional: usize)
[src]
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.
pub fn into_inner(self) -> Result<W, IntoInnerError<Self>>
[src]
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.
pub fn into_inner_with_err(self) -> (W, Option<Error>)
[src]
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.
pub fn into_inner_with_buf(self) -> (W, Buffer)
[src]
pub fn into_inner_with_buf(self) -> (W, Buffer)
Consume self
and return both the underlying writer and the buffer.
Trait Implementations
impl<W: Write> Write for LineWriter<W>
[src]
impl<W: Write> Write for LineWriter<W>
fn write(&mut self, buf: &[u8]) -> Result<usize>
[src]
fn write(&mut self, buf: &[u8]) -> Result<usize>
Write a buffer into this object, returning how many bytes were written. Read more
fn flush(&mut self) -> Result<()>
[src]
fn flush(&mut self) -> Result<()>
Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
1.0.0[src]
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
Attempts to write an entire buffer into this write. Read more
fn write_fmt(&mut self, fmt: Arguments) -> Result<(), Error>
1.0.0[src]
fn write_fmt(&mut self, fmt: Arguments) -> Result<(), Error>
Writes a formatted string into this writer, returning any error encountered. Read more
fn by_ref(&mut self) -> &mut Self
1.0.0[src]
fn by_ref(&mut self) -> &mut Self
Creates a "by reference" adaptor for this instance of Write
. Read more
impl<W: Debug + Write> Debug for LineWriter<W>
[src]
impl<W: Debug + Write> Debug for LineWriter<W>
Auto Trait Implementations
impl<W> !Send for LineWriter<W>
impl<W> !Send for LineWriter<W>
impl<W> !Sync for LineWriter<W>
impl<W> !Sync for LineWriter<W>