IConduit

Conduits provide virtualized access to external content, and represent things like files or Internet connections. Conduits expose a pair of streams, are modelled by ocean.io.model.IConduit, and are implemented via classes such as File & SocketConduit.

Additional kinds of conduit are easy to construct: one either subclasses ocean.io.device.Conduit, or implements ocean.io.model.IConduit. A conduit typically reads and writes from/to an IBuffer in large chunks, typically the entire buffer. Alternatively, one can invoke input.read(dst[]) and/or output.write(src[]) directly.

Members

Functions

bufferSize
size_t bufferSize()

Return a preferred size for buffering conduit I/O.

detach
void detach()

Release external resources.

error
void error(istring msg)

Throw a generic IO exception with the provided msg.

isAlive
bool isAlive()

Is the conduit alive?

toString
istring toString()

Return the name of this conduit.

Interfaces

Seek
interface Seek

All streams now support seek(), so this is used to signal a seekable conduit instead.

Truncate
interface Truncate

Indicates the conduit supports resize/truncation.

Inherited Members

From InputStream

read
size_t read(void[] dst)

Read from stream into a target array. The provided dst will be populated with content from the stream.

load
void[] load(size_t max)

Load the bits from a stream, and return them all in an array. The optional max value indicates the maximum number of bytes to be read.

input
InputStream input()

Return the upstream source.

From OutputStream

write
size_t write(const(void)[] src)

Write to stream from a source array. The provided src content will be written to the stream.

copy
OutputStream copy(InputStream src, size_t max)

Transfer the content of another stream to this one. Returns a reference to this class, and throws IOException on failure.

output
OutputStream output()

Return the upstream sink.

Meta