Skip to main content

send_streaming

Function send_streaming 

Source
pub fn send_streaming<F, T>(
    request: StreamRequest<F>,
) -> Pin<Box<dyn Stream<Item = Result<T, TransportError>> + Send>>
where F: StreamRequestFactory, T: DeserializeOwned + Send + 'static,
Expand description

Send a streaming request and adapt the response into a typed stream, with the open deferred until the stream is first polled.

The returned stream yields Result<T, TransportError> items, one per SSE event or per multipart/mixed part. With reconnect.max_attempts == 0 (the default), a transient transport failure ends the stream immediately. With a non-zero limit, the client re-issues the request up to max_attempts times, applying exponential backoff between attempts — replaying Last-Event-ID under SSE framing, and with no resume token under any other. A multipart/mixed reopen therefore replays the body from its first part, redelivering any items already yielded (at-least-once); see ClientConfig::stream_reconnect.

The open is lazy: nothing is sent until the returned stream is first polled, so a connect failure, a non-success status or a framing-setup failure arrives as the stream’s first item. That is the shape a #[streaming] fn method needs, since it has nowhere else to put an error. Use open_streaming when the open must be able to fail on its own.

§Stability

The StreamRequest parameter is not settled surface — see StreamRequest. This entry point took a positional argument list before a framing selector existed.