Struct std::old_io::BufferedWriterUnstable [-] [+] [src]

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

Wraps a Writer and buffers output to it

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

This writer will be flushed when it is dropped.

Example

fn main() { use std::old_io::{BufferedWriter, File}; let file = File::create(&Path::new("message.txt")).unwrap(); let mut writer = BufferedWriter::new(file); writer.write_str("hello, world").unwrap(); writer.flush().unwrap(); }
use std::old_io::{BufferedWriter, File};

let file = File::create(&Path::new("message.txt")).unwrap();
let mut writer = BufferedWriter::new(file);

writer.write_str("hello, world").unwrap();
writer.flush().unwrap();

Methods

impl<W: Writer> BufferedWriter<W>

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

Creates a new BufferedWriter with the specified buffer capacity

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

Creates a new BufferedWriter with a default 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) -> W

Unwraps this BufferedWriter, returning the underlying writer.

The buffer is flushed before returning the writer.

Trait Implementations

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

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

impl<W: Writer> Writer for BufferedWriter<W>

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

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

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

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

fn write_str(&mut self, s: &str) -> IoResult<()>

fn write_line(&mut self, s: &str) -> IoResult<()>

fn write_char(&mut self, c: char) -> IoResult<()>

fn write_int(&mut self, n: isize) -> IoResult<()>

fn write_uint(&mut self, n: usize) -> IoResult<()>

fn write_le_uint(&mut self, n: usize) -> IoResult<()>

fn write_le_int(&mut self, n: isize) -> IoResult<()>

fn write_be_uint(&mut self, n: usize) -> IoResult<()>

fn write_be_int(&mut self, n: isize) -> IoResult<()>

fn write_be_u64(&mut self, n: u64) -> IoResult<()>

fn write_be_u32(&mut self, n: u32) -> IoResult<()>

fn write_be_u16(&mut self, n: u16) -> IoResult<()>

fn write_be_i64(&mut self, n: i64) -> IoResult<()>

fn write_be_i32(&mut self, n: i32) -> IoResult<()>

fn write_be_i16(&mut self, n: i16) -> IoResult<()>

fn write_be_f64(&mut self, f: f64) -> IoResult<()>

fn write_be_f32(&mut self, f: f32) -> IoResult<()>

fn write_le_u64(&mut self, n: u64) -> IoResult<()>

fn write_le_u32(&mut self, n: u32) -> IoResult<()>

fn write_le_u16(&mut self, n: u16) -> IoResult<()>

fn write_le_i64(&mut self, n: i64) -> IoResult<()>

fn write_le_i32(&mut self, n: i32) -> IoResult<()>

fn write_le_i16(&mut self, n: i16) -> IoResult<()>

fn write_le_f64(&mut self, f: f64) -> IoResult<()>

fn write_le_f32(&mut self, f: f32) -> IoResult<()>

fn write_u8(&mut self, n: u8) -> IoResult<()>

fn write_i8(&mut self, n: i8) -> IoResult<()>

impl<W: Writer> Drop for BufferedWriter<W>

fn drop(&mut self)