Reader interfacev0.1.0

Source
Somewhere bytes come from.
pub interface Reader {
    func Read(
        self: &var Self,
        into: var char8[..]
    ) -> uint ! IoError;
}

Requirements

Read

func Read(
    self: &var Self,
    into: var char8[..]
) -> uint ! IoError

Fills what it can of into and succeeds with how much. A success of zero does not happen for a non-empty buffer: the end of the stream is the EndOfStream failure, so a caller never mistakes silence for data.

NameTypeDescription
intovar char8[..]receives the bytes

Returns: how many bytes were read, which may be fewer than into holds; IsEnd at the end of the stream

Source

Implementations

TypeSummary
ByteReaderA reader of a slice of bytes, from its start.
StandardInStandard input, with the console-versus-redirection question answered at acquisition.

ZeroProgressLimit

pub const ZeroProgressLimit: uint = 3;

How many consecutive zero-progress rounds the looping helpers tolerate before refusing. A transient report is retried without counting; this counts only rounds where the stream reported success and moved nothing, which is a stream that will never finish the job.

Source

ReadExact

pub func ReadExact(
    reader: &var Reader,
    into: var char8[..]
) -> ! IoError

Fills all of into, looping over partial reads, or says why it could not. Transient reports are retried; the end of the stream before the buffer fills is EndOfStream with the buffer partly written — how much is not reported, because a caller who needs the count reads incrementally.

Source

Parameters

NameTypeDescription
reader&var Readerwhere the bytes come from
intovar char8[..]receives the bytes

Returns: success only when into was filled completely; IsEnd when the stream ran out first