[][src]Struct buf_redux::LineWriter

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]

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 new_ringbuf(inner: W) -> Self[src]

Wrap inner with the default buffer capacity using a ringbuffer.

pub fn with_capacity_ringbuf(cap: usize, inner: W) -> Self[src]

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]

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]

fn write_vectored(&mut self, bufs: &[IoSlice]) -> Result<usize, Error>1.36.0[src]

Like write, except that it writes from a slice of buffers. Read more

fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>1.0.0[src]

Attempts to write an entire buffer into this writer. Read more

fn write_fmt(&mut self, fmt: Arguments) -> Result<(), Error>1.0.0[src]

Writes a formatted string into this writer, returning any error encountered. Read more

fn by_ref(&mut self) -> &mut Self1.0.0[src]

Creates a "by reference" adaptor for this instance of Write. Read more

Auto Trait Implementations

impl<W> Sync for LineWriter<W> where
    W: Sync

impl<W> Send for LineWriter<W> where
    W: Send

impl<W> Unpin for LineWriter<W> where
    W: Unpin

impl<W> RefUnwindSafe for LineWriter<W> where
    W: RefUnwindSafe

impl<W> UnwindSafe for LineWriter<W> where
    W: UnwindSafe

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]