zio.blocks.streams

Members list

Type members

Classlikes

Genuinely non-blocking JVM reader factories. NioReaders remains the API for blocking ReadableByteChannels.

Genuinely non-blocking JVM reader factories. NioReaders remains the API for blocking ReadableByteChannels.

Attributes

Source
AsyncNioReaders.scala
Supertypes
class Object
trait Matchable
class Any
Self type
case object BuildInfo

This object was generated by sbt-buildinfo.

This object was generated by sbt-buildinfo.

Attributes

Source
BuildInfo.scala
Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
Self type
BuildInfo.type
sealed abstract class JvmType(val ordinal: Int)

Tag identifying which JVM type A corresponds to: one of the 8 primitives, or AnyRef for reference types.

Tag identifying which JVM type A corresponds to: one of the 8 primitives, or AnyRef for reference types.

Used throughout the streaming library for runtime specialization dispatch:

Identity comparison (eq) is safe because each variant is a singleton case object.

Value parameters

ordinal

Stable integer identifier for serialization or indexing.

Attributes

Companion
object
Source
JvmType.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object AnyRef
object Boolean
object Byte
object Char
object Double
object Float
object Int
object Long
object Short
Show all
object JvmType

Companion enumerating all 8 JVM primitive types plus the AnyRef fallback for reference types. Also contains JvmType.Infer, the type-class that maps Scala types to their JvmType at compile time.

Companion enumerating all 8 JVM primitive types plus the AnyRef fallback for reference types. Also contains JvmType.Infer, the type-class that maps Scala types to their JvmType at compile time.

Attributes

Companion
class
Source
JvmType.scala
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
JvmType.type
object NioReaders

JVM-only factory methods for constructing Reader instances backed by NIO ByteBuffers and ReadableByteChannels.

JVM-only factory methods for constructing Reader instances backed by NIO ByteBuffers and ReadableByteChannels.

Attributes

Source
NioReaders.scala
Supertypes
class Object
trait Matchable
class Any
Self type
NioReaders.type
object NioSinks

JVM-only convenience constructors for creating Sink instances that write to NIO ByteBuffers and WritableByteChannels.

JVM-only convenience constructors for creating Sink instances that write to NIO ByteBuffers and WritableByteChannels.

Each method creates a sink that drains the stream into the corresponding NIO target.

Attributes

Source
NioSinks.scala
Supertypes
class Object
trait Matchable
class Any
Self type
NioSinks.type
object NioStreams

JVM-only convenience constructors for creating Stream instances backed by NIO ByteBuffers and ReadableByteChannels.

JVM-only convenience constructors for creating Stream instances backed by NIO ByteBuffers and ReadableByteChannels.

Each method wraps an NIO source as a Stream.

Attributes

Source
NioStreams.scala
Supertypes
class Object
trait Matchable
class Any
Self type
NioStreams.type
object NioWriters

JVM-only factory methods for constructing Writer instances backed by NIO ByteBuffers and WritableByteChannels.

JVM-only factory methods for constructing Writer instances backed by NIO ByteBuffers and WritableByteChannels.

Attributes

Source
NioWriters.scala
Supertypes
class Object
trait Matchable
class Any
Self type
NioWriters.type
object Pipeline

Companion object for Pipeline. Provides factory constructors for common transformations: map, filter, take, drop, collect, and identity.

Companion object for Pipeline. Provides factory constructors for common transformations: map, filter, take, drop, collect, and identity.

Attributes

Companion
class
Source
Pipeline.scala
Supertypes
class Object
trait Matchable
class Any
Self type
Pipeline.type
abstract class Pipeline[-In, +Out]

A transformation from a Stream[_, In] to a Stream[_, Out]. Pipelines compose sequentially via andThen (with Pipeline.identity as the identity) and can be applied to Streams via applyToStream or to Sinks via applyToSink.

A transformation from a Stream[_, In] to a Stream[_, Out]. Pipelines compose sequentially via andThen (with Pipeline.identity as the identity) and can be applied to Streams via applyToStream or to Sinks via applyToSink.

Type parameters

In

Input element type.

Out

Output element type.

Attributes

Companion
object
Source
Pipeline.scala
Supertypes
class Object
trait Matchable
class Any
object Platform extends PlatformSpecific

Attributes

Companion
trait
Source
Platform.scala
Supertypes
trait Platform
class Object
trait Matchable
class Any
Self type
Platform.type
trait Platform

Cross-platform abstraction for thread management in the streams module.

Cross-platform abstraction for thread management in the streams module.

Platform-specific implementations are provided in:

  • jvm/src/main/scala/zio/blocks/streams/PlatformSpecific.scala (JVM)
  • js/src/main/scala/zio/blocks/streams/PlatformSpecific.scala (JS)

On the JVM, startVirtualThread launches a virtual thread (JDK 21+, detected via reflection) or a raw daemon thread as fallback. On Scala.js there is no concurrency, so supportsConcurrency is false and startVirtualThread throws UnsupportedOperationException.

createBufferedReader is a factory that returns a platform-appropriate buffered reader: concurrent on JVM, synchronous prefetch on JS.

Attributes

Companion
object
Source
Platform.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object Platform
trait PlatformSpecific extends Platform

JVM implementation of the cross-platform Platform capabilities.

JVM implementation of the cross-platform Platform capabilities.

Mixed into the package-level Platform object on JVM, so call sites use the same Platform.* surface regardless of platform.

  • supportsConcurrency is true.
  • startVirtualThread uses Thread.ofVirtual().start(...) reflectively when running on JDK 21+, falling back to a daemon Thread otherwise.
  • createBufferedReader, createMergeReader, and createMapParReader return primitive-specialized readers (Int / Long / Float / Double) when the upstream's JvmType allows it, and the generic AnyRef variants otherwise.

Attributes

Source
PlatformSpecific.scala
Supertypes
trait Platform
class Object
trait Matchable
class Any
Known subtypes
object Platform
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.

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
Supertypes
class Object
trait Matchable
class Any

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.

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
Supertypes
class Object
trait Matchable
class Any
Self type
Sink.type

Attributes

Source
SinkCompanionPlatformSpecific.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object Sink
abstract class Stream[+E, +A] extends StreamPlatformSpecific[E, A]

A lazy, pull-based, resource-safe sequence of elements of type A that may fail with an error of type E.

A lazy, pull-based, resource-safe sequence of elements of type A that may fail with an error of type E.

A Stream is a ''description'': nothing executes until a terminal operation is driven. Cross-platform terminals such as runAsync, runCollectAsync, and headAsync return Async[Either[E, Z]]. The JVM additionally provides blocking terminals such as run, runCollect, and head, which return Either[E, Z]. Left contains typed stream errors; defects fail the outer Async or propagate from a JVM blocking terminal.

Type parameters

A

Element type.

E

Error type.

Attributes

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

Companion object for Stream. Provides factory constructors:

Companion object for Stream. Provides factory constructors:

Attributes

Companion
class
Source
Stream.scala
Supertypes
class Object
trait Matchable
class Any
Self type
Stream.type
trait StreamPlatformSpecific[+E, +A]

Attributes

Source
StreamPlatformSpecific.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class Stream[E, A]
Self type
Stream[E, A]