[−][src]Struct buf_redux::LineWriter
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][−]
pub fn new(inner: W) -> Self
[src][−]
Wrap inner
with the default buffer capacity.
pub fn with_capacity(cap: usize, inner: W) -> Self
[src][−]
Wrap inner
with the given buffer capacity.
pub fn with_buffer(buf: Buffer, inner: W) -> LineWriter<W>
[src][−]
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][−]
Get a reference to the inner writer.
pub fn get_mut(&mut self) -> &mut W
[src][−]
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][−]
Get the capacity of the inner buffer.
pub fn buf_len(&self) -> usize
[src][−]
Get the number of bytes currently in the buffer.
pub fn reserve(&mut self, additional: usize)
[src][−]
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][−]
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][−]
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][−]
Consume self
and return both the underlying writer and the buffer.
Trait Implementations
impl<W: Write + Debug> Debug for LineWriter<W>
[src][+]
impl<W: Write> Write for LineWriter<W>
[src][+]
Auto Trait Implementations
impl<W> RefUnwindSafe for LineWriter<W> where
W: RefUnwindSafe,
W: RefUnwindSafe,
impl<W> Send for LineWriter<W> where
W: Send,
W: Send,
impl<W> Sync for LineWriter<W> where
W: Sync,
W: Sync,
impl<W> Unpin for LineWriter<W> where
W: Unpin,
W: Unpin,
impl<W> UnwindSafe for LineWriter<W> where
W: UnwindSafe,
W: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src][+]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src][+]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src][+]
T: ?Sized,
impl<T> From<T> for T
[src][+]
impl<T, U> Into<U> for T where
U: From<T>,
[src][+]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src][+]
U: Into<T>,
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src][+]
U: TryFrom<T>,