@std/io/streams.ms#
Import each required symbol with import Name from "@std/io/streams.ms".
buffered_reader Function#
Wraps input so small incoming chunks are coalesced into chunks of at least
chunk_bytes bytes (or whatever remains at end of stream). Incoming chunks already
at least chunk_bytes long pass through without extra copying. A chunk_bytes
below 1 fails on the first read with EINVAL.
fn buffered_reader(move input ReadStream[Bytes], chunk_bytes Int = 65536) ReadStream[Bytes] { ... }buffered_writer Function#
Wraps output so small byte writes are batched into chunks of roughly
buffer_bytes before calling the underlying sink. Writes at least buffer_bytes
long pass through without extra copying once any pending bytes are flushed; flush
and close drain pending bytes. A buffer_bytes below 1 fails on the first write
or flush with EINVAL.
fn buffered_writer(move output WriteStream[Bytes], buffer_bytes Int = 65536) WriteStream[Bytes] { ... }collect Function#
Returns every item of input, in order. More than max_items items returns
EOVERFLOW.
fn collect[T](move input ReadStream[T], max_items Int? = null) Result[List[T], Error] { ... }copy Function#
Moves every item of input to output, pulling the next item only after write
accepts the last, then flushes output. Returns the number of items moved.
fn copy[T](move input ReadStream[T], move output WriteStream[T]) Result[Int, Error] { ... }fold Function#
Combines the items of input in order into one value: f takes the value so far
and the next item, starting from start. A failed read returns its error.
fn fold[T, S](move input ReadStream[T], start S, f fn(S, T) S) Result[S, Error] { ... }from_bytes Function#
Returns a stream that yields data in chunks of at most chunk_bytes bytes and
then ends. A chunk_bytes below 1 makes the first read fail with EINVAL.
fn from_bytes(move data Bytes, chunk_bytes Int = 65536) ReadStream[Bytes] { ... }from_list Function#
Returns a stream that yields the items of items in order and then ends.
fn from_list[T](move items List[T]) ReadStream[T] { ... }read_all Function#
Returns all bytes of input. More than max_bytes bytes returns EOVERFLOW.
fn read_all(move input ReadStream[Bytes], max_bytes Int? = null) Result[Bytes, Error] { ... }