SyncReader

zio.blocks.streams.io.Reader.SyncReader
abstract class SyncReader[+Elem] extends Reader[Elem]

Attributes

Source
Reader.scala
Graph
Supertypes
class Reader[Elem]
class Object
trait Matchable
class Any
Known subtypes
Self type
SyncReader[Elem]

Members list

Value members

Abstract methods

def close(): Unit

Signals close from the consumer side. Implementations should set internal closed state and wake any blocked readers.

Signals close from the consumer side. Implementations should set internal closed state and wake any blocked readers.

Attributes

Source
Reader.scala
def isClosed: Boolean

true once the reader is closed. Reflects the state machine; does not imply the buffer is empty.

true once the reader is closed. Reflects the state machine; does not imply the buffer is empty.

Attributes

Source
Reader.scala
def read[A >: Elem](sentinel: A): A

Reads the next element, or returns sentinel if the stream is closed. The caller passes a sentinel value that can never appear as a real element; getting it back means the stream is exhausted.

Reads the next element, or returns sentinel if the stream is closed. The caller passes a sentinel value that can never appear as a real element; getting it back means the stream is exhausted.

Attributes

Source
Reader.scala

Concrete methods

final def ++[Elem2 >: Elem](next: => SyncReader[Elem2])(implicit dummy: DummyImplicit): SyncReader[Elem2]

Attributes

Source
Reader.scala
final override def ++[Elem2 >: Elem](next: => Reader[Elem2]): AsyncReader[Elem2]

Alias for concat.

Alias for concat.

Attributes

Definition Classes
Source
Reader.scala
final def concat[Elem2 >: Elem](next: () => SyncReader[Elem2])(implicit dummy: DummyImplicit): SyncReader[Elem2]

Attributes

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

Attributes

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

Attributes

Source
Reader.scala
final protected def failSource(value: Any): Nothing

Fails immediately with a trusted typed source error.

Fails immediately with a trusted typed source error.

Attributes

Source
Reader.scala
override def jvmType: JvmType

The primitive type of elements in this reader, or AnyRef for reference types. Specialized subclasses override this to enable zero-boxing pull paths via readIntPhysical(), readLongPhysical(), etc.

The primitive type of elements in this reader, or AnyRef for reference types. Specialized subclasses override this to enable zero-boxing pull paths via readIntPhysical(), readLongPhysical(), etc.

Attributes

Definition Classes
Source
Reader.scala
def readAll[A >: Elem](): Chunk[A]

Drains this reader into a Chunk, consuming all remaining elements. Returns Chunk.empty when already at EOF. Dispatches on jvmType for zero-boxing on primitive streams.

Drains this reader into a Chunk, consuming all remaining elements. Returns Chunk.empty when already at EOF. Dispatches on jvmType for zero-boxing on primitive streams.

Attributes

Source
Reader.scala
def readBoolean(_sentinel: Int)(implicit _ev: Elem <:< Boolean): Int

Sentinel-return Boolean pull. Returns 1 for true, 0 for false, or sentinel when closed and empty. Sentinel must be outside [0, 1]. A typical sentinel is -1. Requires implicit evidence that Elem is a subtype of Boolean.

Sentinel-return Boolean pull. Returns 1 for true, 0 for false, or sentinel when closed and empty. Sentinel must be outside [0, 1]. A typical sentinel is -1. Requires implicit evidence that Elem is a subtype of Boolean.

Attributes

Source
Reader.scala
def readByte(): Int

Reads a single byte, returning -1 when closed. Default delegates to read and extracts the low byte. Byte-specialized readers override for efficiency.

Reads a single byte, returning -1 when closed. Default delegates to read and extracts the low byte. Byte-specialized readers override for efficiency.

Attributes

Source
Reader.scala
def readBytes(buf: Array[Byte], offset: Int, len: Int)(implicit ev: Elem <:< Byte): Int

Box-free bulk byte pull into a caller-supplied buffer. Requires compile-time evidence that this reader's element type is Byte.

Box-free bulk byte pull into a caller-supplied buffer. Requires compile-time evidence that this reader's element type is Byte.

Contract mirrors java.io.InputStream.read(byte[], int, int):

  • Blocks until at least 1 byte is available.
  • Returns the number of bytes read (`1 0) process(buf, 0, n) }}}

Attributes

Source
Reader.scala
def readChar(_sentinel: Int)(implicit _ev: Elem <:< Char): Int

Sentinel-return Char pull. Returns element widened to Int, or sentinel when closed. Requires implicit evidence that Elem is a subtype of Char.

Sentinel-return Char pull. Returns element widened to Int, or sentinel when closed. Requires implicit evidence that Elem is a subtype of Char.

Attributes

Source
Reader.scala
def readDouble(_sentinel: Double)(implicit _ev: Elem <:< Double): Double

Sentinel-return Double pull. Returns element widened/exact, or sentinel when closed. Requires implicit evidence that Elem is a subtype of Double.

Sentinel-return Double pull. Returns element widened/exact, or sentinel when closed. Requires implicit evidence that Elem is a subtype of Double.

Attributes

Source
Reader.scala
def readDoubles(buf: Array[Double], offset: Int, maxLen: Int)(implicit ev: Elem <:< Double): Int

Box-free bulk Double pull into a caller-supplied buffer.

Box-free bulk Double pull into a caller-supplied buffer.

Contract mirrors readBytes:

  • Blocks until at least 1 element is available.
  • Returns the number of elements read (1 &lt;= r &lt;= maxLen).
  • Returns -1 when closed and empty.
  • Returns 0 immediately when maxLen == 0.

Value parameters

buf

destination array

maxLen

maximum number of elements to read

offset

starting position in buf

Attributes

Returns

number of elements read, -1 on end-of-stream, or 0 when maxLen == 0

Source
Reader.scala
def readFloat(_sentinel: Double)(implicit _ev: Elem <:< Float): Double

Sentinel-return Float pull. Returns element widened to Double, or sentinel when closed. Requires implicit evidence that Elem is a subtype of Float.

Sentinel-return Float pull. Returns element widened to Double, or sentinel when closed. Requires implicit evidence that Elem is a subtype of Float.

Attributes

Source
Reader.scala
def readFloats(buf: Array[Float], offset: Int, maxLen: Int)(implicit ev: Elem <:< Float): Int

Box-free bulk Float pull into a caller-supplied buffer.

Box-free bulk Float pull into a caller-supplied buffer.

Contract mirrors readBytes:

  • Blocks until at least 1 element is available.
  • Returns the number of elements read (1 &lt;= r &lt;= maxLen).
  • Returns -1 when closed and empty.
  • Returns 0 immediately when maxLen == 0.

Value parameters

buf

destination array

maxLen

maximum number of elements to read

offset

starting position in buf

Attributes

Returns

number of elements read, -1 on end-of-stream, or 0 when maxLen == 0

Source
Reader.scala
def readInt(_sentinel: Long)(implicit _ev: Elem <:< Int): Long

Sentinel-return Int pull. Returns the element widened to Long, or sentinel when closed and empty. The sentinel must lie outside [Int.MinValue, Int.MaxValue] (e.g. Long.MinValue). Requires implicit evidence that Elem is a subtype of Int.

Sentinel-return Int pull. Returns the element widened to Long, or sentinel when closed and empty. The sentinel must lie outside [Int.MinValue, Int.MaxValue] (e.g. Long.MinValue). Requires implicit evidence that Elem is a subtype of Int.

Attributes

Source
Reader.scala
def readInts(buf: Array[Int], offset: Int, maxLen: Int)(implicit ev: Elem <:< Int): Int

Box-free bulk Int pull into a caller-supplied buffer.

Box-free bulk Int pull into a caller-supplied buffer.

Contract mirrors readBytes:

  • Blocks until at least 1 element is available.
  • Returns the number of elements read (1 &lt;= r &lt;= maxLen).
  • Returns -1 when closed and empty.
  • Returns 0 immediately when maxLen == 0.

Value parameters

buf

destination array

maxLen

maximum number of elements to read

offset

starting position in buf

Attributes

Returns

number of elements read, -1 on end-of-stream, or 0 when maxLen == 0

Source
Reader.scala
def readLong(_sentinel: Long)(implicit _ev: Elem <:< Long): Long

Sentinel-return Long pull. Returns the element, or sentinel when closed and empty. The sentinel must be a value that never appears in the stream (e.g. Long.MaxValue). Requires implicit evidence that Elem is a subtype of Long.

Sentinel-return Long pull. Returns the element, or sentinel when closed and empty. The sentinel must be a value that never appears in the stream (e.g. Long.MaxValue). Requires implicit evidence that Elem is a subtype of Long.

Attributes

Source
Reader.scala
def readLongs(buf: Array[Long], offset: Int, maxLen: Int)(implicit ev: Elem <:< Long): Int

Box-free bulk Long pull into a caller-supplied buffer.

Box-free bulk Long pull into a caller-supplied buffer.

Contract mirrors readBytes:

  • Blocks until at least 1 element is available.
  • Returns the number of elements read (1 &lt;= r &lt;= maxLen).
  • Returns -1 when closed and empty.
  • Returns 0 immediately when maxLen == 0.

Value parameters

buf

destination array

maxLen

maximum number of elements to read

offset

starting position in buf

Attributes

Returns

number of elements read, -1 on end-of-stream, or 0 when maxLen == 0

Source
Reader.scala
def readN[A >: Elem](n: Int): Chunk[A]

Reads at most n elements into a Chunk, returning early if the reader is exhausted. Returns Chunk.empty when n &lt;= 0 or the reader is already closed. Dispatches on jvmType for zero-boxing on primitive streams.

Reads at most n elements into a Chunk, returning early if the reader is exhausted. Returns Chunk.empty when n &lt;= 0 or the reader is already closed. Dispatches on jvmType for zero-boxing on primitive streams.

Attributes

Source
Reader.scala
def readShort(_sentinel: Int)(implicit _ev: Elem <:< Short): Int

Sentinel-return Short pull. Returns element widened to Int, or sentinel when closed. Requires implicit evidence that Elem is a subtype of Short.

Sentinel-return Short pull. Returns element widened to Int, or sentinel when closed. Requires implicit evidence that Elem is a subtype of Short.

Attributes

Source
Reader.scala
def readUpToN[A >: Elem](n: Int): Chunk[A]

Reads up to n elements that are currently available. Blocks for at least 1 element if none are ready yet. Returns fewer than n if fewer are available without additional blocking. Returns Chunk.empty if n &lt;= 0 or if the reader is closed and empty.

Reads up to n elements that are currently available. Blocks for at least 1 element if none are ready yet. Returns fewer than n if fewer are available without additional blocking. Returns Chunk.empty if n &lt;= 0 or if the reader is closed and empty.

Differs from readN in that readN blocks until exactly n elements have been read. readUpToN returns as soon as at least one element is read, without waiting for further elements.

Value parameters

n

maximum number of elements to read

Attributes

Returns

a Chunk with between 1 and n elements, or empty on EOS

Source
Reader.scala
def readable(): Boolean

Returns true if the next read() / readIntPhysical() etc. would return a value (not closed/sentinel). Default implementation returns !isClosed. Subclasses with buffered state should override for accuracy.

Returns true if the next read() / readIntPhysical() etc. would return a value (not closed/sentinel). Default implementation returns !isClosed. Subclasses with buffered state should override for accuracy.

Attributes

Source
Reader.scala
def reset(): Unit

Rewinds this reader to its initial state, as if freshly constructed. After reset(), all elements are available again from the beginning.

Rewinds this reader to its initial state, as if freshly constructed. After reset(), all elements are available again from the beginning.

Not all readers support this. Readers backed by one-shot resources (InputStreams, java.io.Readers) throw UnsupportedOperationException.

Attributes

Source
Reader.scala
def setLimit(n: Long): Boolean

Attempts to set a limit on this reader so it produces at most n elements. Returns true if the reader handled it natively (O(1), zero per-element cost), false if it cannot. When true, the reader will produce at most limit elements before reporting closed. After reset(), the limit is re-applied from the new start position.

Attempts to set a limit on this reader so it produces at most n elements. Returns true if the reader handled it natively (O(1), zero per-element cost), false if it cannot. When true, the reader will produce at most limit elements before reporting closed. After reset(), the limit is re-applied from the new start position.

Default returns false — most readers don't support native pushdown.

Attributes

Source
Reader.scala
def setRepeat(): Boolean

Attempts to set this reader into repeat-forever mode, so it restarts from the beginning whenever it would otherwise close. Returns true if the reader handled it natively, false if the caller must wrap in a repeating wrapper.

Attempts to set this reader into repeat-forever mode, so it restarts from the beginning whenever it would otherwise close. Returns true if the reader handled it natively, false if the caller must wrap in a repeating wrapper.

Default returns false.

Attributes

Source
Reader.scala
def setSkip(n: Long): Boolean

Attempts to set a skip (drop) on this reader. Returns true if the reader handled it natively (O(1), zero per-element cost), false if it cannot. When true, the next skip elements will be skipped before producing. After reset(), the skip is re-applied.

Attempts to set a skip (drop) on this reader. Returns true if the reader handled it natively (O(1), zero per-element cost), false if it cannot. When true, the next skip elements will be skipped before producing. After reset(), the skip is re-applied.

Default returns false — most readers don't support native pushdown.

Attributes

Source
Reader.scala
def skip(n: Long): Unit

Eagerly discards the first n elements. Returns Unit. If the stream closes before n elements, returns early. Subclasses should override for efficient skipping (e.g. index advancement).

Eagerly discards the first n elements. Returns Unit. If the stream closes before n elements, returns early. Subclasses should override for efficient skipping (e.g. index advancement).

Attributes

Source
Reader.scala
final protected def sourceError(value: Any): StreamError

Constructs a trusted typed source failure for custom Reader implementations.

Constructs a trusted typed source failure for custom Reader implementations.

Attributes

Source
Reader.scala
final def toAsync: AsyncReader[Elem]

Attributes

Source
Reader.scala
def withRelease(release: () => Unit): SyncReader[Elem]

Wraps this reader so that release runs after close().

Wraps this reader so that release runs after close().

Value parameters

release

Action to execute when this reader is closed.

Attributes

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

Attributes

Source
Reader.scala