Skip to content

Change HTTPClientRequestBody.produce into ConcludingAsyncWriter.write#54

Open
guoye-zhang wants to merge 1 commit intoapple:mainfrom
guoye-zhang:produce
Open

Change HTTPClientRequestBody.produce into ConcludingAsyncWriter.write#54
guoye-zhang wants to merge 1 commit intoapple:mainfrom
guoye-zhang:produce

Conversation

@guoye-zhang
Copy link
Contributor

HTTPClientRequestBody.produce(into:) sounds weirdly backwards. I think it's more natural to think about writing in terms of the writer, so I'm hoping to flip it into ConcludingAsyncWriter.write as an extension.

@guoye-zhang guoye-zhang added the ⚠️ semver/major Breaks existing public API. label Dec 22, 2025
@czechboy0
Copy link
Contributor

Since these are equivalent, I don't have a strong lean, but I thought that functions that produce bytes into writers are usually that - functions that take a writer as a parameter. Rather than extensions on writer for each type that might be written.

One reason is that if many types want to write into the writer, then the Writer type itself can get many function overloads, which might get harder to use.

So I probably prefer:

extension Producer {
  func write(into writer: Writer) async throws
}

over:

extension Writer {
  func write(_ producer: Producer) async throws
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

⚠️ semver/major Breaks existing public API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments