Trait std::old_io::WriterUnstable [-] [+] [src]

pub trait Writer {
    fn write_all(&mut self, buf: &[u8]) -> IoResult<()>;

    fn write(&mut self, buf: &[u8]) -> IoResult<()> { ... }
    fn flush(&mut self) -> 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<()> { ... }
}

A trait for objects which are byte-oriented streams. Writers are defined by one method, write. This function will block until the provided buffer of bytes has been entirely written, and it will return any failures which occur.

Another commonly overridden method is the flush method for writers such as buffered writers.

Writers are intended to be composable with one another. Many objects throughout the I/O and related libraries take and provide types which implement the Writer trait.

Required Methods

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

Write the entirety of a given buffer

Errors

If an error happens during the I/O operation, the error is returned as Err. Note that it is considered an error if the entire buffer could not be written, and if an error is returned then it is unknown how much data (if any) was actually written.

Provided Methods

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

Deprecated, this method was renamed to write_all

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

Flush this output stream, ensuring that all intermediately buffered contents reach their destination.

This is by default a no-op and implementers of the Writer trait should decide whether their stream needs to be buffered or not.

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

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

This method is primarily used to interface with the format_args! macro, but it is rare that this should explicitly be called. The write! macro should be favored to invoke this method instead.

Errors

This function will return any I/O error reported while formatting.

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

Write a rust string into this sink.

The bytes written will be the UTF-8 encoded version of the input string. If other encodings are desired, it is recommended to compose this stream with another performing the conversion, or to use write with a converted byte-array instead.

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

Writes a string into this sink, and then writes a literal newline (\n) byte afterwards. Note that the writing of the newline is not atomic in the sense that the call to write is invoked twice (once with the string and once with a newline character).

If other encodings or line ending flavors are desired, it is recommended that the write method is used specifically instead.

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

Write a single char, encoded as UTF-8.

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

Write the result of passing n through int::to_str_bytes.

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

Write the result of passing n through uint::to_str_bytes.

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

Write a little-endian uint (number of bytes depends on system).

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

Write a little-endian int (number of bytes depends on system).

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

Write a big-endian uint (number of bytes depends on system).

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

Write a big-endian int (number of bytes depends on system).

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

Write a big-endian u64 (8 bytes).

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

Write a big-endian u32 (4 bytes).

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

Write a big-endian u16 (2 bytes).

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

Write a big-endian i64 (8 bytes).

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

Write a big-endian i32 (4 bytes).

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

Write a big-endian i16 (2 bytes).

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

Write a big-endian IEEE754 double-precision floating-point (8 bytes).

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

Write a big-endian IEEE754 single-precision floating-point (4 bytes).

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

Write a little-endian u64 (8 bytes).

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

Write a little-endian u32 (4 bytes).

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

Write a little-endian u16 (2 bytes).

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

Write a little-endian i64 (8 bytes).

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

Write a little-endian i32 (4 bytes).

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

Write a little-endian i16 (2 bytes).

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

Write a little-endian IEEE754 double-precision floating-point (8 bytes).

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

Write a little-endian IEEE754 single-precision floating-point (4 bytes).

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

Write a u8 (1 byte).

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

Write an i8 (1 byte).

Implementors