Struct std::io::BufWriter
[−]
[src]
pub struct BufWriter<W: Write> { // some fields omitted }
Wraps a Writer and buffers output to it
It can be excessively inefficient to work directly with a Write
`Write. For example, every call to
`. For
example, every call to write
`writeon
` on TcpStream
`TcpStreamresults in a system call. A
` results in a system call. A
BufWriter
`BufWriterkeeps an in memory buffer of data and writes it to the underlying
` keeps an in memory buffer of data and writes it to the
underlying Write
`Write` in large, infrequent batches.
The buffer will be written out when the writer is dropped.
Methods
impl<W: Write> BufWriter<W>
fn new(inner: W) -> BufWriter<W>
Creates a new BufWriter
`BufWriter` with a default buffer capacity
fn with_capacity(cap: usize, inner: W) -> BufWriter<W>
Creates a new BufWriter
`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
`BufWriter`, returning the underlying writer.
The buffer is written out before returning the writer.