Companion object for Sink. Provides factory constructors for common consumers: fail, create, drain, count, collectAll, foldLeft, foreach, head, last, take, exists, forall, find, fromOutputStream, fromJavaWriter, sumInt, sumLong, sumFloat, and sumDouble.
Attributes
- Companion
- class
- Source
- Sink.scala
- Graph
-
- Supertypes
- Self type
-
Sink.type
Members list
Value members
Concrete methods
Consumes the entire input and returns its elements, in order, in a Chunk. Empty input yields an empty chunk. Primitive inputs use specialized chunk builders. Collection stops if the upstream stream fails or the run is cancelled.
Consumes the entire input and returns its elements, in order, in a Chunk. Empty input yields an empty chunk. Primitive inputs use specialized chunk builders. Collection stops if the upstream stream fails or the run is cancelled.
Attributes
- Source
- Sink.scala
Creates a sink whose callback receives the run's asynchronous reader and decides how much input to consume and what result to produce. Returning early leaves the remaining input unread; the enclosing stream run then closes its reader, so it is not exposed as reusable leftover input.
Creates a sink whose callback receives the run's asynchronous reader and decides how much input to consume and what result to produce. Returning early leaves the remaining input unread; the enclosing stream run then closes its reader, so it is not exposed as reusable leftover input.
The callback and reader are valid only for the run and must not be retained. Reader failures preserve the stream's typed error; callback exceptions or failed effects are defects. Cancellation is propagated to pending reader operations and closes the run's resources. On the JVM, a synchronous terminal blocks on this asynchronous implementation.
Attributes
- Source
- Sink.scala
Creates a sink with independent native synchronous and asynchronous callbacks. The terminal selects exactly one callback; both must implement the same consumption and result semantics.
Creates a sink with independent native synchronous and asynchronous callbacks. The terminal selects exactly one callback; both must implement the same consumption and result semantics.
Each callback controls how much input it consumes. Input left unread is closed with the enclosing run rather than returned as leftovers, and the reader must not escape the callback. Reader failures remain typed stream errors; callback exceptions and failed asynchronous effects are defects. Cancellation of the asynchronous callback propagates through its reader.
Attributes
- Source
- Sink.scala
Tests elements in order and returns true at the first one satisfying pred; otherwise consumes the entire input and returns false (including for empty input). After a match, no further elements are pulled and unread input is closed with the run. Exceptions from pred are defects.
Tests elements in order and returns true at the first one satisfying pred; otherwise consumes the entire input and returns false (including for empty input). After a match, no further elements are pulled and unread input is closed with the run. Exceptions from pred are defects.
Attributes
- Source
- Sink.scala
Sequentially tests elements with pred, returning true and stopping at the first successful predicate, or false at end-of-stream. At most one predicate effect runs at a time; no effect is started for unread input. Predicate failure or cancellation fails or cancels the run as a defect.
Sequentially tests elements with pred, returning true and stopping at the first successful predicate, or false at end-of-stream. At most one predicate effect runs at a time; no effect is started for unread input. Predicate failure or cancellation fails or cancels the run as a defect.
Attributes
- Source
- Sink.scala
A sink that immediately fails with error e without consuming any elements. The failure is reported in the typed error channel; the enclosing run closes the unread input and its resources.
A sink that immediately fails with error e without consuming any elements. The failure is reported in the typed error channel; the enclosing run closes the unread input and its resources.
Attributes
- Source
- Sink.scala
Tests elements in order and returns the first one satisfying pred. Returns None only after consuming an input with no match. A match short-circuits without pulling later elements; unread input is closed with the run. Exceptions from pred are defects.
Tests elements in order and returns the first one satisfying pred. Returns None only after consuming an input with no match. A match short-circuits without pulling later elements; unread input is closed with the run. Exceptions from pred are defects.
Attributes
- Source
- Sink.scala
Sequentially tests elements and returns the first one for which pred produces true, or None at end-of-stream. It short-circuits with at most one predicate effect running; predicate failure or cancellation fails or cancels the run as a defect.
Sequentially tests elements and returns the first one for which pred produces true, or None at end-of-stream. It short-circuits with at most one predicate effect running; predicate failure or cancellation fails or cancels the run as a defect.
Attributes
- Source
- Sink.scala
Strictly left-folds the entire input from z, invoking f in encounter order. Empty input returns z. Exceptions from f are defects. The JvmType.Infer evidence selects unboxed primitive input/accumulator paths where supported; it does not alter the result.
Strictly left-folds the entire input from z, invoking f in encounter order. Empty input returns z. Exceptions from f are defects. The JvmType.Infer evidence selects unboxed primitive input/accumulator paths where supported; it does not alter the result.
Attributes
- Source
- Sink.scala
Strictly left-folds the entire input from z, running one f effect at a time in encounter order. Empty input returns z. Effect failure or cancellation fails or cancels the run as a defect. JvmType.Infer keeps the API aligned with specialized synchronous folds; semantics are identical.
Strictly left-folds the entire input from z, running one f effect at a time in encounter order. Empty input returns z. Effect failure or cancellation fails or cancels the run as a defect. JvmType.Infer keeps the API aligned with specialized synchronous folds; semantics are identical.
Attributes
- Source
- Sink.scala
Tests elements in order and returns false at the first one that does not satisfy pred; otherwise consumes the entire input and returns true (including for empty input). After a mismatch, unread input is closed with the run. Exceptions from pred are defects.
Tests elements in order and returns false at the first one that does not satisfy pred; otherwise consumes the entire input and returns true (including for empty input). After a mismatch, unread input is closed with the run. Exceptions from pred are defects.
Attributes
- Source
- Sink.scala
Sequentially tests elements, returning false and stopping at the first predicate result of false, or true at end-of-stream. At most one effect runs at a time; predicate failure or cancellation fails or cancels the run as a defect.
Sequentially tests elements, returning false and stopping at the first predicate result of false, or true at end-of-stream. At most one effect runs at a time; predicate failure or cancellation fails or cancels the run as a defect.
Attributes
- Source
- Sink.scala
Consumes the entire input, invoking f once per element in encounter order, and returns Unit. An exception from f is a defect and stops consumption. Primitive reader lanes avoid boxing where supported.
Consumes the entire input, invoking f once per element in encounter order, and returns Unit. An exception from f is a defect and stops consumption. Primitive reader lanes avoid boxing where supported.
Attributes
- Source
- Sink.scala
Consumes the entire input, invoking f sequentially in encounter order, and returns Unit. At most one callback effect runs at a time. Callback failure or cancellation fails or cancels the run as a defect and stops pulling input.
Consumes the entire input, invoking f sequentially in encounter order, and returns Unit. At most one callback effect runs at a time. Callback failure or cancellation fails or cancels the run as a defect and stops pulling input.
Attributes
- Source
- Sink.scala
Consumes the entire input and writes each character, in order, to w, then returns Unit. Writes are synchronous even during an asynchronous stream run. This sink neither flushes nor closes the writer; its owner remains responsible for both. An I/O exception is a defect and stops consumption.
Consumes the entire input and writes each character, in order, to w, then returns Unit. Writes are synchronous even during an asynchronous stream run. This sink neither flushes nor closes the writer; its owner remains responsible for both. An I/O exception is a defect and stops consumption.
Attributes
- Source
- Sink.scala
Consumes the entire input and writes each byte, in order, to os, then returns Unit. Bytes are written as unsigned values from 0 through 255. Writes are synchronous even during an asynchronous stream run. This sink neither flushes nor closes the stream; its owner remains responsible for both. An I/O exception is a defect and stops consumption.
Consumes the entire input and writes each byte, in order, to os, then returns Unit. Bytes are written as unsigned values from 0 through 255. Writes are synchronous even during an asynchronous stream run. This sink neither flushes nor closes the stream; its owner remains responsible for both. An I/O exception is a defect and stops consumption.
Attributes
- Source
- Sink.scala
Pulls at most one element, returning it in Some, or None for empty input. It short-circuits after the first element; remaining input is not pulled and is closed with the enclosing run. Primitive reader lanes are used where supported.
Pulls at most one element, returning it in Some, or None for empty input. It short-circuits after the first element; remaining input is not pulled and is closed with the enclosing run. Primitive reader lanes are used where supported.
Attributes
- Source
- Sink.scala
Consumes the entire input and returns its last element in Some, or None for empty input. Primitive reader lanes are consumed without boxing where supported.
Consumes the entire input and returns its last element in Some, or None for empty input. Primitive reader lanes are consumed without boxing where supported.
Attributes
- Source
- Sink.scala
Collects at most the first n elements, in order, into a Chunk. If n <= 0, it returns an empty chunk without pulling input; if the input ends first, it returns all available elements. Reaching n short-circuits, and remaining input is closed with the enclosing run rather than returned as leftovers. Primitive inputs use specialized chunk builders.
Collects at most the first n elements, in order, into a Chunk. If n <= 0, it returns an empty chunk without pulling input; if the input ends first, it returns all available elements. Reaching n short-circuits, and remaining input is closed with the enclosing run rather than returned as leftovers. Primitive inputs use specialized chunk builders.
Attributes
- Source
- Sink.scala
Inherited methods
Creates a JVM sink whose blocking callback receives the run's synchronous reader and decides how much input to consume and what result to produce. Returning early leaves the remaining input unread; the enclosing stream run closes that input rather than exposing it as reusable leftovers.
Creates a JVM sink whose blocking callback receives the run's synchronous reader and decides how much input to consume and what result to produce. Returning early leaves the remaining input unread; the enclosing stream run closes that input rather than exposing it as reusable leftovers.
The callback and reader are valid only for the run and must not be retained. Reader failures preserve the stream's typed error; callback exceptions are defects. At an asynchronous terminal, the callback runs on the blocking executor and cancellation closes the reader.
Attributes
- Inherited from:
- SinkCompanionPlatformSpecific
- Source
- SinkCompanionPlatformSpecific.scala
Concrete fields
Consumes the entire input and returns its element count as a Long (0L for empty input). The count wraps on Long overflow. Primitive reader lanes are consumed without boxing where supported.
Consumes the entire input and returns its element count as a Long (0L for empty input). The count wraps on Long overflow. Primitive reader lanes are consumed without boxing where supported.
Attributes
- Source
- Sink.scala
Consumes and discards the entire input, returning Unit. It stops only at end-of-stream, upstream failure, or cancellation, and uses specialized primitive reader lanes where supported.
Consumes and discards the entire input, returning Unit. It stops only at end-of-stream, upstream failure, or cancellation, and uses specialized primitive reader lanes where supported.
Attributes
- Source
- Sink.scala
Consumes all Double elements and sums them from 0.0 using Double arithmetic. Empty input yields 0.0; overflow, infinities, and NaN follow normal IEEE 754 semantics.
Consumes all Double elements and sums them from 0.0 using Double arithmetic. Empty input yields 0.0; overflow, infinities, and NaN follow normal IEEE 754 semantics.
Attributes
- Source
- Sink.scala
Consumes all Float elements and sums them from 0.0 in a Double accumulator, reducing intermediate rounding loss. Empty input yields 0.0; infinities and NaN follow normal IEEE 754 semantics. The specialized float reader path avoids boxing.
Consumes all Float elements and sums them from 0.0 in a Double accumulator, reducing intermediate rounding loss. Empty input yields 0.0; infinities and NaN follow normal IEEE 754 semantics. The specialized float reader path avoids boxing.
Attributes
- Source
- Sink.scala
Consumes all Int elements and sums them from 0L in a Long accumulator. Empty input yields 0L; overflow wraps according to Long arithmetic. The specialized int reader path avoids boxing.
Consumes all Int elements and sums them from 0L in a Long accumulator. Empty input yields 0L; overflow wraps according to Long arithmetic. The specialized int reader path avoids boxing.
Attributes
- Source
- Sink.scala
Consumes all Long elements and sums them from 0L. Empty input yields 0L; overflow wraps according to Long arithmetic.
Consumes all Long elements and sums them from 0L. Empty input yields 0L; overflow wraps according to Long arithmetic.
Attributes
- Source
- Sink.scala