Fix dioxus-fullstack::Streaming<T,E> only deserializing one client value #4975
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This patch fixes a structural issue in the implementation of
FromResponseandFromRequestforStreaming<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:
FromRequestandFromResponseare now implemented forStreaming<T, E>only whenE: Encoding + 'static.Previously, the
'staticbound was not required. In practice, most (if not all)Encodingimplementations are'static, so downstream crates are unlikely to break. However, it remains a technically breaking change and should be noted.