Skip to content

Conversation

@Kannen
Copy link

@Kannen Kannen commented Nov 17, 2025

This patch fixes a structural issue in the implementation of FromResponse and FromRequest for Streaming<T, E>.

Until now, the implementation implicitly assumed that each Bytes chunk returned by the underlying byte stream contained exactly one encoded value of type T.
However, if the stream already contained multiple encoded values at the time the response/request body was built, all of those values were consumed and encoded into the outgoing body, but only the first value was ever decoded on the receiving side.

This patch corrects that behavior by:

  • properly iterating over each Bytes chunk returned by the underlying stream,

  • decoding all frames contained in each chunk,

  • and flattening the result into a correct Stream<Item = T>.

As a result, every value present in the byte stream is now decoded and transmitted as expected.

In addition, this patch introduces stricter error handling:
if a received frame is malformed—i.e., if the chunk does not contain a valid sequence of encoded items—the decoder will now return StreamingError::Decoding. This prevents silently dropping or partially decoding data.

Interface Change

This patch also introduces a visible API adjustment:
FromRequest and FromResponse are now implemented for Streaming<T, E> only when E: Encoding + 'static.
Previously, the 'static bound was not required. In practice, most (if not all) Encoding implementations are 'static, so downstream crates are unlikely to break. However, it remains a technically breaking change and should be noted.

@Kannen Kannen requested a review from a team as a code owner November 17, 2025 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant