Reader interfacev0.1.0
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.
| Name | Type | Description |
|---|---|---|
into | var char8[..] | receives the bytes |
Returns: how many bytes were read, which may be fewer than into holds; IsEnd at the end of the stream
Implementations
| Type | Summary |
|---|---|
ByteReader | A reader of a slice of bytes, from its start. |
StandardIn | Standard input, with the console-versus-redirection question answered at acquisition. |
Related
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.
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.
Parameters
| Name | Type | Description |
|---|---|---|
reader | &var Reader | where the bytes come from |
into | var char8[..] | receives the bytes |
Returns: success only when into was filled completely; IsEnd when the stream ran out first