Sink

zio.blocks.streams.Sink
See theSink companion object
abstract class Sink[+E, -A, +Z]

A consumer of elements of type A that may fail with E and, on completion, produces a result Z. Sinks are consumed by passing them to Stream.runAsync (or a platform-specific terminal): the stream compiles into a io.Reader and drains it once to produce the final result.

Type parameters

A

Input element type (contravariant).

E

Error type.

Z

Result type.

Attributes

Companion
object
Source
Sink.scala
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def contramap[A0 <: A, A2](g: A2 => A0)(implicit jtA0: Infer[A0]): Sink[E, A2, Z]

Applies g to each element as this sink requests it, then feeds the transformed element to this sink. Consumption and short-circuiting are therefore unchanged; g is not evaluated for unread input. Exceptions thrown by g are defects, not values in the sink's typed error channel.

Applies g to each element as this sink requests it, then feeds the transformed element to this sink. Consumption and short-circuiting are therefore unchanged; g is not evaluated for unread input. Exceptions thrown by g are defects, not values in the sink's typed error channel.

Attributes

Source
Sink.scala
def contramapAsync[A0 <: A, A2](g: A2 => encoding.Async[A0])(implicit jtA0: Infer[A0]): Sink[E, A2, Z]

Sequentially applies the asynchronous function g to each element as this sink requests it. Consumption and short-circuiting are unchanged, so g is not started for unread input. Failure or cancellation of g fails or cancels the run as a defect and stops pulling input.

Sequentially applies the asynchronous function g to each element as this sink requests it. Consumption and short-circuiting are unchanged, so g is not started for unread input. Failure or cancellation of g fails or cancels the run as a defect and stops pulling input.

Attributes

Source
Sink.scala
def map[Z2](f: Z => Z2): Sink[E, A, Z2]

Transforms this sink's successful result after it completes. This does not change input consumption or typed errors. Exceptions thrown by f are defects.

Transforms this sink's successful result after it completes. This does not change input consumption or typed errors. Exceptions thrown by f are defects.

Attributes

Source
Sink.scala
def mapAsync[Z2](f: Z => encoding.Async[Z2]): Sink[E, A, Z2]

Asynchronously transforms this sink's successful result after it completes. The effect is not started when the sink fails, and it does not change input consumption. Effect failure or cancellation fails or cancels the run as a defect.

Asynchronously transforms this sink's successful result after it completes. The effect is not started when the sink fails, and it does not change input consumption. Effect failure or cancellation fails or cancels the run as a defect.

Attributes

Source
Sink.scala
def mapError[E2](f: E => E2)(implicit isNothing: IsNothing[E]): Sink[E2, A, Z]

Transforms a typed sink error with f, without changing consumption or successful results. Upstream stream errors and defects are not transformed. For an infallible sink (E = Nothing), the evidence avoids allocating a wrapper and f can never be evaluated.

Transforms a typed sink error with f, without changing consumption or successful results. Upstream stream errors and defects are not transformed. For an infallible sink (E = Nothing), the evidence avoids allocating a wrapper and f can never be evaluated.

Attributes

Source
Sink.scala
def mapErrorAsync[E2](f: E => encoding.Async[E2])(implicit isNothing: IsNothing[E]): Sink[E2, A, Z]

Asynchronously transforms a typed sink error with f. Upstream stream errors, successful results, and defects are unchanged. For E = Nothing, f can never be evaluated; otherwise failure or cancellation of f fails or cancels the run as a defect.

Asynchronously transforms a typed sink error with f. Upstream stream errors, successful results, and defects are unchanged. For E = Nothing, f can never be evaluated; otherwise failure or cancellation of f fails or cancels the run as a defect.

Attributes

Source
Sink.scala