Function textOutput
Take a text-based iopipe and turn it into an output range of dchar
. Note
that the iopipe must be an output iopipe, not an input one. In other words,
a textOutput
result doesn't output its input, it uses its input as a place
to deposit data.
auto textOutput(Chain)
(
Chain c
);
The given iopipe window will be written to, then data that is ready to be output is released. It is expected that the iopipe will use this mechanism to actually know which data to output. See the example for more information.
Parameters
Name | Description |
---|---|
c | The output iopipe that can be used to put dchars into. |
Returns
An output range that can accept all forms of text data for output.
Example
import std .range : put;
// use a writeable buffer as output.
char[256] buffer;
size_t written = 0;
// this helps us see how many chars are written.
struct LocalIopipe
{
char[] window;
void release(size_t elems)
{
window .release(elems);
written += elems;
}
size_t extend(size_t elems) { return 0; }
}
auto oRange = LocalIopipe(buffer[]) .textOutput;
put(oRange, "hello, world");
// written is updated whenever the iopipe is released
assert(buffer[0 .. written] == "hello, world");