Lyricdev
GitHub

interface Writer

pub interface Writer

A sink of bytes. write takes from the front of the slice and returns how many bytes it took — maybe fewer than it was handed; writeAll takes the rest. flush hands on what a writer holds back; one that holds nothing back keeps the default, which does nothing.

Why a write throws Cancelled, as a read does (Reader): a write into a socket or a pipe waits for as long as its reader takes nothing — without bound —, and a cancel ends that wait with Cancelled, not with an IoError a handler would take for the stream's. A writer that never waits without bound declares throws IoError alone.

Methods

mut fn write(from: Slice<uint8>): int throws [IoError, Cancelled]
mut fn flush(): void throws [IoError, Cancelled]