Stream

The base class for all streams.

Streams are a common interface for reading/writing a 'stream' of bytes.

Other classes can be built on top of streams, such as the BinaryIO class to provide more specific functionality to streams.

Constructors

this
this(Can can)

Members

Enums

Can
enum Can

A flag enum specifying what the stream is capable of doing.

SeekFrom
enum SeekFrom

Used with seek.

Functions

copyTo
void copyTo(Stream to, ubyte[] buffer)

Copies data from the current position in this stream to the end of this stream, into the given stream. The given stream is written to using it's current position as well.

copyToAlloc
void copyToAlloc(Stream to, size_t bufferSize)
void copyToAlloc(Stream to, size_t bufferSize, Alloc alloc)

A helper function for copyTo, that uses a buffer created from an std.experimental.allocator Allocator. The buffer is of course disposed of afterwards.

copyToGC
void copyToGC(Stream to, size_t bufferSize)

A helper function for copyTo, that uses a buffer allocated by the GC.

copyToStack
void copyToStack(Stream to)

A helper function for copyTo, that uses a buffer placed on the stack.

dispose
void dispose()

Disposes of the stream's resources.

flush
void flush()

Flushes the stream's data.

read
ubyte[] read(size_t amount)

Creates a GC-allocated buffer with a specified size, and attempts to read in a certain amount of bytes.

readToBuffer
ubyte[] readToBuffer(ubyte[] buffer)

Reads bytes from the stream into a buffer.

seek
void seek(SeekFrom from, ptrdiff_t amount)

Seeks somewhere into the stream.

seekCurr
void seekCurr(ptrdiff_t amount)

Shortcut for seek(SeekFrom.Current)

seekEnd
void seekEnd(ptrdiff_t amount)

Shortcut for seek(SeekFrom.End)

seekStart
void seekStart(ptrdiff_t amount)

Shortcut for seek(SeekFrom.Start)

write
const(ubyte[]) write(ubyte[] data)

Writes bytes into the stream.

Properties

can
Can can [@property getter]
canRead
bool canRead [@property getter]
canSeek
bool canSeek [@property getter]
canTimeout
bool canTimeout [@property getter]
canWrite
bool canWrite [@property getter]
isDisposed
bool isDisposed [@property getter]
length
size_t length [@property setter]

Sets the length of the stream's data.

length
size_t length [@property getter]

Gets the length of the stream's data.

position
size_t position [@property setter]

Sets the position of the stream's 'cursor'.

position
size_t position [@property getter]

Gets the position of the stream's 'cursor'.

readTimeout
Duration readTimeout [@property setter]

Sets the read timeout for the stream.

readTimeout
Duration readTimeout [@property getter]

Gets the read timeout for the stream.

writeTimeout
Duration writeTimeout [@property setter]

Sets the write timeout for the stream.

writeTimeout
Duration writeTimeout [@property getter]

Gets the write timeout for the stream.

Meta