v0.4.0

Writer interfacev0.1.0

Source
Somewhere bytes go.
pub interface Writer {
    func Write(
        &var self,
        bytes: char8[..]
    ) -> uint throws IoError;
    func Flush(&var self) throws IoError;
}

Requirements

Write

func Write(
    &var self,
    bytes: char8[..]
) -> uint throws IoError

Takes what it can of bytes and succeeds with how much.

NameTypeDescription
byteschar8[..]the bytes to write

Returns: how many bytes were taken, which may be fewer than offered

Source

Flush

func Flush(&var self) throws IoError

Pushes whatever is held toward the destination.

Returns: success when everything held reached the destination

Source

Implementations

TypeSummary
ByteWriterA writer that keeps what is written in a growing block of memory.
StandardOutStandard output: a byte Writer whose encoding matches where the bytes land.
StandardErrorStandard error: the same contract as standard output, on the stream reports belong to.

WriteAll

pub func WriteAll(
    writer: &var Writer,
    bytes: char8[..]
) throws IoError

Writes all of bytes, looping over partial writes, or says why it could not. Interruptions are retried at once. A writer that accepts nothing while reporting success is refused with WriteZero after ZeroProgressLimit rounds: a loop that spins on it would hang the caller on a stream that will never take the rest. Any other failure, WouldBlock included, is returned as itself, with some of bytes possibly written and how much not reported: a caller writing to a non-blocking stream writes incrementally with Write.

Source

Parameters

NameTypeDescription
writer&var Writerthe destination
byteschar8[..]the bytes to write

Returns: success only when every byte was written, looping over short writes