From d0b4a06d0f173a2f3be27d3ea21b3c3aa18db440 Mon Sep 17 00:00:00 2001 From: Franz Busch Date: Thu, 14 May 2026 23:42:25 +0200 Subject: [PATCH] Rework `AsyncStreaming` protocols to use generic `RangeReplaceableContainer` buffers (#417) Replace `InputSpan`/`OutputSpan` with generic `Buffer` associated types constrained to `RangeReplaceableContainer` across all four streaming protocols. This sidesteps the limitation that `OutputSpan` (and other `~Escapable` types) cannot be used in async contexts today, while still allowing conforming types to choose a buffer representation optimized for their use case (e.g. `UniqueArray` for heap-backed storage, or a future stack-allocated container for embedded). Switch callee-owned protocols from `consuming` to `inout` closure semantics, rename `forEachChunk` to `forEachBuffer`, and move `forEach`/`collect` to future directions in the proposal. Adds test coverage for `AsyncWriter`, `CallerAsyncReader`, and `EitherError`. Updates all documentation to reflect the new API surface. --- Sources/AsyncStreaming/NNNN-async-streaming.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/AsyncStreaming/NNNN-async-streaming.md b/Sources/AsyncStreaming/NNNN-async-streaming.md index d21c89f..3d317da 100644 --- a/Sources/AsyncStreaming/NNNN-async-streaming.md +++ b/Sources/AsyncStreaming/NNNN-async-streaming.md @@ -147,7 +147,7 @@ The bite-sized pseudocode: ``` protocol AsyncReader { - // Callee provides a full buffer; caller processes it + // Callee provides a full buffer; caller drains it func read(body: (inout buffer) throws -> R) throws -> R }