Replies: 2 comments
|
Scope defined — description above updated with the concrete Two things worth calling out that were deliberately left out of this proposal:
Compression/encryption (byte-level transforms, not value serializers) stay out of scope for this proposal and would need their own streaming-shaped protocol if pursued later. Milestone moved to 4.1.0. |
0 replies
|
Implemented in #265 — |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Overview
Adds
PayloadEncoder, a public protocol that lets consumers plug in their own serialization format (e.g. Protobuf, MessagePack) forPayload, the same wayPayload(_:encoder:contentType:)already does today forEncodable+JSONEncoder.API
Usage:
Scope decisions
.file(URL)source.PayloadEncoderturns a typed Swift value intoData. Sending an existing file verbatim is already covered byPayload(url:contentType:). A serializer (Protobuf/MessagePack) never operates on an arbitrary file the way a byte-transform (gzip, encryption) would; an earlier draft tried a singlePayloadSource<T>enum with both a.value(T)and a.file(URL)case to cover both, but the file case ended up carrying a meaningless genericT. That was the signal the two concerns don't belong in the same protocol.encode. A single Protobuf/MessagePack message is an atomic blob — there's no meaningful "encode this message in pieces" the way compressing a byte stream is.RequestBodyalready streams whateverDatathis produces to the wire in chunks on its own (Internals.StreamWriterSequence), so nothing is lost by keepingencodea plain, one-shotthrows -> Data.Content-Encoding, orthogonal toContent-Type), not value serializers — mixing them intoPayloadEncoderis what produced the awkward shape above. A genuinely streamed transform needs its own protocol (progressive output, not-> Data) and its own proposal; tracked separately and does not block this one.Milestone: 4.1.0
All reactions