Skip to main content

decode

Function decode 

Source
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 itemYieldedStream continues?
data (deserializes)Ok(ClientEvent::Data(e))yes
data (does not)Err(ClientError::Decode)no
progressOk(ClientEvent::Progress)yes
errorErr(ClientError::Remote)no
requestskippedyes
donenothingno
transport failureErr(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.