package io
Provides various ways to work with streams that perform IO.
These methods accept a cats.effect.Blocker, as the underlying
implementations perform blocking IO.
- Alphabetic
- By Inheritance
- io
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Package Members
Type Members
Value Members
- def readInputStream[F[_]](fis: F[InputStream], chunkSize: Int, blocker: Blocker, closeAfterUse: Boolean = true)(implicit F: Sync[F], cs: ContextShift[F]): Stream[F, Byte]
Reads all bytes from the specified
InputStreamwith a buffer size ofchunkSize.Reads all bytes from the specified
InputStreamwith a buffer size ofchunkSize. SetcloseAfterUseto false if theInputStreamshould not be closed after use. - def readOutputStream[F[_]](blocker: Blocker, chunkSize: Int)(f: (OutputStream) => F[Unit])(implicit arg0: Concurrent[F], arg1: ContextShift[F]): Stream[F, Byte]
Take a function that emits to an OutputStream effectfully, and return a stream which, when run, will perform that function and emit the bytes recorded in the OutputStream as an fs2.Stream
Take a function that emits to an OutputStream effectfully, and return a stream which, when run, will perform that function and emit the bytes recorded in the OutputStream as an fs2.Stream
The stream produced by this will terminate if:
freturnsfcallsOutputStream#close
If none of those happens, the stream will run forever.
- def stdin[F[_]](bufSize: Int, blocker: Blocker)(implicit arg0: Sync[F], arg1: ContextShift[F]): Stream[F, Byte]
Stream of bytes read asynchronously from standard input.
- def stdinUtf8[F[_]](bufSize: Int, blocker: Blocker)(implicit arg0: Sync[F], arg1: ContextShift[F]): Stream[F, String]
Stream of
Stringread asynchronously from standard input decoded in UTF-8. - def stdout[F[_]](blocker: Blocker)(implicit arg0: Sync[F], arg1: ContextShift[F]): Pipe[F, Byte, Unit]
Pipe of bytes that writes emitted values to standard output asynchronously.
- def stdoutLines[F[_], O](blocker: Blocker, charset: Charset = utf8Charset)(implicit arg0: Sync[F], arg1: ContextShift[F], arg2: Show[O]): Pipe[F, O, Unit]
Writes this stream to standard output asynchronously, converting each element to a sequence of bytes via
Showand the givenCharset.Writes this stream to standard output asynchronously, converting each element to a sequence of bytes via
Showand the givenCharset.Each write operation is performed on the supplied execution context. Writes are blocking so the execution context should be configured appropriately.
- def toInputStream[F[_]](implicit F: ConcurrentEffect[F]): Pipe[F, Byte, InputStream]
Pipe that converts a stream of bytes to a stream that will emit a single
java.io.InputStream, that is closed whenever the resulting stream terminates.Pipe that converts a stream of bytes to a stream that will emit a single
java.io.InputStream, that is closed whenever the resulting stream terminates.If the
closeof resulting input stream is invoked manually, then this will await until the original stream completely terminates.Because all
InputStreammethods block (includingclose), the resultingInputStreamshould be consumed on a different thread pool than the one that is backing theConcurrentEffect.Note that the implementation is not thread safe -- only one thread is allowed at any time to operate on the resulting
java.io.InputStream. - def toInputStreamResource[F[_]](source: Stream[F, Byte])(implicit F: ConcurrentEffect[F]): Resource[F, InputStream]
Like toInputStream but returns a
Resourcerather than a single element stream. - def unsafeReadInputStream[F[_]](fis: F[InputStream], chunkSize: Int, blocker: Blocker, closeAfterUse: Boolean = true)(implicit F: Sync[F], cs: ContextShift[F]): Stream[F, Byte]
Reads all bytes from the specified
InputStreamwith a buffer size ofchunkSize.Reads all bytes from the specified
InputStreamwith a buffer size ofchunkSize. SetcloseAfterUseto false if theInputStreamshould not be closed after use.Each read operation is performed on the supplied blocker.
Recycles an underlying input buffer for performance. It is safe to call this as long as whatever consumes this
Streamdoes not store theChunkreturned or pipe it to a combinator that does (e.g.buffer). UsereadInputStreamfor a safe version. - def writeOutputStream[F[_]](fos: F[OutputStream], blocker: Blocker, closeAfterUse: Boolean = true)(implicit F: Sync[F], cs: ContextShift[F]): Pipe[F, Byte, Unit]
Writes all bytes to the specified
OutputStream.Writes all bytes to the specified
OutputStream. SetcloseAfterUseto false if theOutputStreamshould not be closed after use.Each write operation is performed on the supplied execution context. Writes are blocking so the execution context should be configured appropriately.
- object Watcher