interface Reader
pub interface Reader
A source of bytes. read fills the slice it is handed from the front and returns how many
bytes it put there: 0 only at the end, and at once for an empty slice — fewer than the
slice holds is no end.
Why a read throws Cancelled: a read from a socket or a pipe waits for as long as nothing
comes — without bound. withTimeout and the end of a task's scope stop a task that waits
there, and the read ends with Cancelled, as every other wait does. It is not an
IoErrorKind: a catch (e: IoError) would take the cancel for a failure of the stream, and a
loop that reads again after one would never stop. A reader that never waits without bound —
memory, a file, the console, whose calls end in bounded time — declares throws IoError
alone: an implementation throws at most what the member allows. Code over any reader
(R :: [Reader]) is told both.
Methods
mut fn read(into: Slice<uint8>): int throws [IoError, Cancelled]