Implementation of resource for channels where resource needs to be flushed at the end of processing.
Like resource, but the release action may emit a final value,
useful for flushing any internal buffers.
Like resource, but the release action may emit a final value,
useful for flushing any internal buffers. NB: In the event of an
error, this final value is ignored.
Creates a Channel[Task,Int,ByteVector] from an InputStream by
repeatedly requesting the given number of bytes.
Creates a Channel[Task,Int,ByteVector] from an InputStream by
repeatedly requesting the given number of bytes. The last chunk
may be less than the requested size.
This implementation requires an array allocation for each read.
To recycle the input buffer, use unsafeChunkR.
This implementation closes the InputStream when finished
or in the event of an error.
Creates a Sink from an OutputStream, which will be closed
when this Process is halted.
Creates a Channel from a file name and optional buffer size in bytes.
Creates a Sink from a file name and optional buffer size in bytes.
Creates a Sink from a file name and optional buffer size in bytes.
if true, then bytes will be written to the end of the file rather than the beginning
A Sink which, as a side effect, adds elements to the given Buffer.
Create a Process from an iterator.
Create a Process from an iterator. The value behind the iterator should be
immutable and not rely on an external resource. If that is not the case, use
io.iteratorR.
Create a Process from an iterator that is tied to some resource,
R (like a file handle) that we want to ensure is released.
Create a Process from an iterator that is tied to some resource,
R (like a file handle) that we want to ensure is released.
See linesR for an example use.
is the resource
is a value in the iterator
acquires the resource
releases the resource
creates the iterator from the resource
Creates a Process[Task,String] from the lines of the Source,
using the iteratorR combinator to ensure the Source is closed
when processing the stream of lines is finished.
Creates a Process[Task,String] from the lines of the InputStream,
using the iteratorR combinator to ensure the InputStream is closed
when processing the stream of lines is finished.
Creates a Process[Task,String] from the lines of a file, using
the iteratorR combinator to ensure the file is closed
when processing the stream of lines is finished.
Turn a PrintStream into a Sink.
Turn a PrintStream into a Sink. This Sink does not
emit newlines after each element. For that, use printLines.
Turn a PrintStream into a Sink.
Turn a PrintStream into a Sink. This Sink emits
newlines after each element. If this is not desired, use print.
Creates Sink from an PrintStream using f to perform
specific side effects on that PrintStream.
Generic combinator for producing a Process[F,O] from some
effectful O source.
Generic combinator for producing a Process[F,O] from some
effectful O source. The source is tied to some resource,
R (like a file handle) that we want to ensure is released.
See chunkW for an example use.
The standard input stream, as Process.
The standard input stream, as Process. This Process repeatedly awaits
and emits chunks of bytes from standard input.
The standard input stream, as Process.
The standard input stream, as Process. This Process repeatedly awaits
and emits lines from standard input.
The standard output stream, as a Sink.
The standard output stream, as a Sink. This Sink does not
emit newlines after each element. For that, use stdOutLines.
The standard output stream, as a ByteVector Sink.
The standard output stream, as a Sink.
The standard output stream, as a Sink. This Sink emits
newlines after each element. If this is not desired, use stdOut.
Converts a source to a mutable InputStream.
Converts a source to a mutable InputStream. The resulting input stream
should be reasonably efficient and supports early termination (i.e. all
finalizers associated with the input process will be run if the stream is
closed).
Creates a Channel[Task,Array[Byte],Array[Byte]] from an InputStream by
repeatedly filling the input buffer.
Creates a Channel[Task,Array[Byte],Array[Byte]] from an InputStream by
repeatedly filling the input buffer. is.read will be called multiple times
as needed; however, the last chunk may be less than the requested size.
It is safe to recycle the same buffer for consecutive reads
as long as whatever consumes this Process never stores the Array[Byte]
returned or pipes it to a combinator (like buffer) that does.
Use chunkR for a safe version of this combinator - this takes
an Int number of bytes to read and allocates a fresh Array[Byte]
for each read.
This implementation closes the InputStream when finished
or in the event of an error.
Module of
Processfunctions and combinators for file and network I/O.