pub fn decode<'a, E>(items: ItemStream<'a>) -> EventStream<'a, E>where
E: DeserializeOwned + 'a,Expand description
Decode a transport’s wire items into a method’s typed events.
The mapping, exhaustively:
| Wire item | Yielded | Stream continues? |
|---|---|---|
data (deserializes) | Ok(ClientEvent::Data(e)) | yes |
data (does not) | Err(ClientError::Decode) | no |
progress | Ok(ClientEvent::Progress) | yes |
error | Err(ClientError::Remote) | no |
request | skipped | yes |
done | nothing | no |
| transport failure | Err(ClientError::Transport) | no |
Both terminal errors end the stream because both mean the server will
send nothing further that is meaningful: an in-band error is the hub’s
last word on the call (stream_sse_response and the buffered REST path
both stop there), and a decode failure means client and server disagree
about the event type, so every subsequent item would fail the same way.
A done item is not surfaced as an event — normal completion is the
stream ending. Ok(())-style sentinels in a Stream only invite
consumers to forget to handle them.