forwardTo method

Future<int> forwardTo(
  1. WASIComponentWritableStream<T> writable,
  2. int maxElements, {
  3. int chunkSize = 1,
})

Forwards up to maxElements values into writable.

Already queued values are moved directly between stream queues. Pending source reads and bounded destination writes reuse the existing async wait primitives so forwarding follows the same cancellation, drop, and backpressure behavior as canonical read/write operations. chunkSize bounds fallback buffering when the source has no queued values yet.

Implementation

Future<int> forwardTo(
  WASIComponentWritableStream<T> writable,
  int maxElements, {
  int chunkSize = 1,
}) {
  return _state.forwardTo(writable._state, maxElements, chunkSize: chunkSize);
}