streams.types.mapping

This module defines "mapping" input and output streams, which map elements of a wrapped stream to another type. For example, a mapping input stream could wrap around an input stream of strings, and parse each one as an int.

Mapping streams generally operate using a templated function alias; that is, you provide a function at compile-time, and a stream on which to operate. The mapping function should take a single argument, and produce a result of any type. However, if your function returns a MapResult type (as defined in this module), the mapping streams will acknowledge any stream errors that occur.

Members

Aliases

MapResult
alias MapResult(E) = Either!(StreamError, "error", E, "element")

A return type to use when a mapping function could encounter an error. Mapping streams have a special case to treat this return type.

Functions

mappingInputStreamFor
MappingInputStream!(f, S) mappingInputStreamFor(S stream)

Creates a mapping input stream that applies the function f to all elements read from the stream.

mappingOutputStreamFor
MappingOutputStream!(f, S) mappingOutputStreamFor(S stream)

Creates a mapping output stream that applies the function f to all elements written to the stream.

Structs

MappingInputStream
struct MappingInputStream(alias f, S)

An input stream that wraps another stream, and applies a function to each element read from that stream.

MappingOutputStream
struct MappingOutputStream(alias f, S)

An output stream that applies a function to each element that's written to it before writing to the underlying stream.

Meta