Skip to main content

decode_stream

Function decode_stream 

Source
pub fn decode_stream<'b, S, F, D, P, T>(
    stream: S,
    framer: D,
    parser: P,
    options: &DecodeOptions,
) -> impl Stream<Item = Result<T, StreamError>> + Send + 'b
where S: Stream<Item = Result<Bytes, Error>> + Send + 'b, D: Decoder<Item = F, Error = StreamError> + Send + 'b, P: FrameParser<F, T> + Send + 'b, F: 'b,
Expand description

Decode a stream of body chunks into a stream of items.

The byte stream’s error type is std::io::Error because that is what both hyper and reqwest body streams already produce, and what StreamReader requires.

Framing errors and per-record deserialisation errors are flattened into one stream here, but the difference stays observable: after a framing error the stream ends, after a deserialisation error it continues with the next record.

Note what is not required: T: 'b. Neither the framer nor the parser mentions T in its own type for formats that can separate the two, so callers are not forced to add an outlives bound to their public signatures.