streams.functions

A collection of helper functions for working with streams.

Members

Functions

readAll
Either!(E[], "data", StreamError, "error") readAll(S stream)

Reads all available elements from an input stream, and collects them in an allocated buffer. If calling hasData() on the return value of this function returns true, you need to free that data yourself, as it has been allocated via malloc.

readOne
Either!(T, "element", StreamError, "error") readOne(S stream)

Reads exactly one element from an input stream.

transferTo
StreamResult transferTo(I input, O output, Optional!ulong maxElements)

Transfers elements from an input stream to an output stream, doing so continuously until the input stream reads 0 elements or an error occurs. The streams are not closed after transfer completes.

writeOne
OptionalStreamError writeOne(S stream, T value)

Writes exactly one element to an output stream.

Meta