Writer interfacev0.1.0

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

Requirements

Write

func Write(
    self: &var Self,
    bytes: char8[..]
) -> uint ! 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(self: &var Self) -> ! 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[..]
) -> ! IoError

Writes all of bytes, looping over partial writes, or says why it could not. A writer that accepts nothing while reporting success is refused with WriteZero after a few rounds: a loop that spins on it would hang the caller on a stream that will never take the rest.

Source

Parameters

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

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