Reader

zio.blocks.streams.io.Reader
See theReader companion object
abstract class Reader[+Elem]

A pull-based source of elements. Returns elements until closed.

==Thread safety== Reader instances are ''not'' thread-safe. They are designed for single-threaded, pull-based consumption. Do not share a Reader across threads without external synchronization.

==Termination== The read method returns elements while available, or a caller-chosen sentinel when closed. For errors, read throws — either the raw exception, or a StreamError wrapping non-Throwable error values. See zio.blocks.streams.internal.StreamError.

==Sentinel-return protocol== Specialized methods (readInt, readLong, etc.) widen the return type and use a caller-chosen sentinel for end-of-stream. These are the hot-path zero-boxing pull methods.

'''Sentinel choice:''' The Int lane uses Long.MinValue (safe because no Int value widens to Long.MinValue). Long and Double paths that must distinguish end-of-stream use the identity-only EndOfStream marker so every value remains representable. The Float lane uses Double.MaxValue (safe because Float.MaxValue widened to Double is distinct from Double.MaxValue).

==Laws==

  • isClosed is monotone: once true it never returns false.
  • When isClosed and buffer is empty: read(sentinel) returns the sentinel.

Type parameters

Elem

Element type produced by this reader.

Attributes

Companion
object
Source
Reader.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class AsyncReader[Elem]
class SyncReader[Elem]

Members list

Value members

Abstract methods

def ++[Elem2 >: Elem](next: => Reader[Elem2]): Reader[Elem2]

Alias for concat.

Alias for concat.

Attributes

Source
Reader.scala
def concat[Elem2 >: Elem](next: () => Reader[Elem2]): Reader[Elem2]

Attributes

Source
Reader.scala
def concatAsync[Elem2 >: Elem](next: () => encoding.Async[Reader[Elem2]]): AsyncReader[Elem2]

Attributes

Source
Reader.scala
def withReleaseAsync(release: () => encoding.Async[Unit]): AsyncReader[Elem]

Attributes

Source
Reader.scala

Concrete methods

The primitive representation lane used by this reader.

The primitive representation lane used by this reader.

Attributes

Source
Reader.scala