Other Streams
Apart from the streams mentioned previously, the standard library provides a number of different streams for various purposes:
-
core.io.BufferedOStream
Buffered output stream.
Buffers up to
n
bytes before writing to the output stream. This is useful when writing to network streams and/or SSL streams, where there might be some overhead in writing many small chunks.The buffering means that it is important to call
flush
at appropriate times to synchronize communication. -
core.io.LazyMemIStream
A stream that lazily loads data from another stream. This is used to make other streams seekable. Note that
length
will be updated throughout the lifetime of the stream. -
core.io.MemIStream
A stream that reads from a memory buffer.
-
core.io.MemOStream
A stream that writes to a memory buffer.
-
core.io.MeterOStream
A stream that meters the number of bytes written to it, so that it is possible to store offsets to data structures in the file.
-
core.io.PeekIStream
Helper class that provides limited buffering to support seeking without a native peek operation on the underlying stream.
-
core.io.Pipe
A class that contains two streams, an input and an output, that are connected to each other in a manner similar to a POSIX pipe.
The class has a circular buffer of a fixed size (4 KB by default). When a thread attempts to read from an empty pipe, the thread is blocked. The same happens when a thread attempts to write to a full pipe.
The pipe may be used to communicate between different threads, as each end of the pipe remain pointing to the same logical pipe even after they are copied. This is not the case for the Pipe class itself, however.