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==
isClosedis monotone: oncetrueit never returnsfalse.- When
isClosedand 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
- Known subtypes