we (web engine): Experimental web browser project to understand the limits of Claude
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

Implement Streams API: pipeTo, pipeThrough, tee, and byte streams (BYOB) #183

open opened by pierrelf.com

Goal#

Extend the Streams API foundation with pipe operations and the byte-oriented variants needed to model network and binary I/O.

Depends on: "Implement Streams API foundation".

Scope#

  • Pipe operations on ReadableStream
    • pipeTo(destination, options?) where options is { preventClose, preventAbort, preventCancel, signal }
    • pipeThrough({ readable, writable }, options?)
    • AbortSignal integration — aborting the signal aborts the pipe in both directions
    • Backpressure: do not pull until the destination's writer ready resolves
    • Error propagation: errors on either side propagate based on preventClose / preventAbort / preventCancel
  • tee() on ReadableStream
    • Returns a two-element array of branches sharing one underlying source
    • Both branches see the same chunks; closing/erroring is independent unless both cancel
  • Byte streams
    • new ReadableStream({ type: 'bytes', ... })
    • ReadableByteStreamController: enqueue(chunk: Uint8Array), close, error, desiredSize, byobRequest
    • ReadableStreamBYOBReader: getReader({ mode: 'byob' }), read(view)Promise<{ value: Uint8Array, done }>, releaseLock, cancel
    • ReadableStreamBYOBRequest: view, respond(bytesWritten), respondWithNewView(view)
    • Auto-allocate path when constructor specifies autoAllocateChunkSize
  • Pull-throttling: byte stream controllers only call pull while there is demand from a default reader (queued requests) or a BYOB reader (pending view requests)

Acceptance Criteria#

  • readable.pipeTo(writable) resolves when the source closes and the sink finishes draining, rejecting on either side's error
  • readable.pipeThrough(transformStream) returns the transform's readable side and propagates errors
  • Aborting an AbortSignal passed to pipeTo cancels the source and aborts the sink (subject to preventCancel / preventAbort)
  • tee() branches independently consume the same data; cancelling both branches cancels the source
  • BYOB reader returns Uint8Array views with byteOffset/byteLength matching the bytes filled by the underlying source
  • Auto-allocate streams synthesize views of the configured size for the controller to fill
  • Unit tests covering pipe error propagation in all 4 prevent-flag combinations, tee correctness with backpressure, BYOB read with both auto-allocate and consumer-provided views
  • Conventions
    • cargo fmt --all --check
    • cargo clippy --workspace -- -D warnings
    • cargo test --workspace
sign up or login to add to the discussion
Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:meotu43t6usg4qdwzenk4s2t/sh.tangled.repo.issue/3mly7pex5rw2p