Lyricdev
GitHub

class BufWriter

pub class BufWriter<W :: [Writer]> :: [Writer, Closeable]

Conforms to Writer, Closeable.

A Writer with a buffer of its own: what it is handed waits there until 8 KiB are together, a flush() or a close(). A write at least as large as the buffer goes to the inner writer directly. It is Closeable, and one nothing closes is warned about: its last bytes would stay in the buffer. Closing flushes and leaves the inner writer open — it is the caller's (using let f = …; using let w = BufWriter.new(f); closes w first). It throws what its inner writer may (Writer).

Methods

pub static fn new(inner: W): BufWriter<W>
pub mut fn write(from: Slice<uint8>): int throws [IoError, Cancelled]
pub mut fn flush(): void throws [IoError, Cancelled]

Writes what is held, then flushes the inner writer.

Errors

Throws what the inner writer's write or flush throws, and Other { code = 0 } where it takes no byte.

pub fn close(): void throws [IoError, Cancelled]

Flushes as flush() does; the inner writer stays open.

Errors

Throws what flush() throws.