Struct std::io::BufWriterUnstable [-] [+] [src]

pub struct BufWriter<W> {
    // some fields omitted
}

Wraps a Writer and buffers output to it

It can be excessively inefficient to work directly with a Write. For example, every call to write on TcpStream results in a system call. A BufWriter keeps an in memory buffer of data and writes it to the underlying Write in large, infrequent batches.

This writer will be flushed when it is dropped.

Methods

impl<W: Write> BufWriter<W>

fn new(inner: W) -> BufWriter<W>

Creates a new BufWriter with a default buffer capacity

fn with_capacity(cap: usize, inner: W) -> BufWriter<W>

Creates a new BufWriter with the specified buffer capacity

fn get_ref(&self) -> &W

Gets a reference to the underlying writer.

fn get_mut(&mut self) -> &mut W

Gets a mutable reference to the underlying write.

Warning

It is inadvisable to directly read from the underlying writer.

fn into_inner(self) -> Result<W, IntoInnerError<BufWriter<W>>>

Unwraps this BufWriter, returning the underlying writer.

The buffer is flushed before returning the writer.

Trait Implementations

impl<W: Write> Write for BufWriter<W>

fn write(&mut self, buf: &[u8]) -> Result<usize>

fn flush(&mut self) -> Result<()>

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

fn write_fmt(&mut self, fmt: Arguments) -> Result<()>

impl<W> Debug for BufWriter<W> where W: Debug

fn fmt(&self, fmt: &mut Formatter) -> Result

impl<W: Write> Drop for BufWriter<W>

fn drop(&mut self)