zio.blocks.streams.io

Members list

Type members

Classlikes

object Reader

Attributes

Companion
class
Source
Reader.scala
Supertypes
class Object
trait Matchable
class Any
Self type
Reader.type
abstract class Reader[+Elem]

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

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
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class AsyncReader[Elem]
class SyncReader[Elem]
object Writer

Companion object for Writer. Provides factory constructors for common sinks: closed, single, limited, fromOutputStream, and fromWriter.

Companion object for Writer. Provides factory constructors for common sinks: closed, single, limited, fromOutputStream, and fromWriter.

Attributes

Companion
class
Source
Writer.scala
Supertypes
class Object
trait Matchable
class Any
Self type
Writer.type
abstract class Writer[-Elem]

The write-side dual of Reader: a producer pushes elements and observes when the channel is done. Used internally by channel-based implementations and available directly for push-based integration.

The write-side dual of Reader: a producer pushes elements and observes when the channel is done. Used internally by channel-based implementations and available directly for push-based integration.

==Thread safety== Writer instances are ''not'' thread-safe unless otherwise documented. They are designed for single-threaded push-based production.

==Termination== A writer is closed by calling close (clean) or fail (with error). After close, write returns false. After fail, subclasses that override fail may cause write to throw the stored error; the default fail simply delegates to close. Both are idempotent; only the first call wins.

==Laws==

  • isClosed is monotone: once true it never returns false.
  • After isClosed: write returns false (clean close) or throws (error close, if the subclass implements error storage via fail).

Type parameters

Elem

Element type (contravariant).

Attributes

Companion
object
Source
Writer.scala
Supertypes
class Object
trait Matchable
class Any