Reference

std/stream

Streams: one flow in one direction, with a reading end and a writing end.

"Stream" is the word for the flow, not a type. What a signature names is one of its two ends - Source<Item, Failure> to read from, Sink<Item, Failure> to write into - and they are the asynchronous siblings of Iterator and Accumulator, with the same verbs (next, add, finish). Everything in between, every map, filter and framer, is a Stage of std/iteration and is written once for both worlds.

const all = response.body.through(Json.items<User>()).checked().toList().await()?
File.write(path, response.body.mapFailure(IoError.from)).await()?

See docs/design/STREAMS.md for the whole model: the contracts of both ends, what is synchronous and what has to wait, the drivers, and what was taken from Rust, C#, Swift, Scala, Java, Node, Web Streams and Bun.

Modules

Everything