Skip to main content

open_streaming

Function open_streaming 

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

Open a stream eagerly: connect, check the response status, and perform the framing’s own setup before returning, so an open-time failure is an Err from this call rather than the returned stream’s first item.

This is the entry point for a contract method declared #[streaming] async fn — a stream whose open is a distinct, fallible operation. Open-time failures (a 404, a 409 carrying a domain Problem, a 410) reach the caller before any item exists, where its open-time error handling can act on them.

The request’s reconnect policy governs the open as well as the stream: with ReconnectConfig::disabled (the StreamRequest::new default, and what generated code passes for a fallible open per D6) exactly one open attempt is made.

§Errors

Returns TransportError when the request cannot be built, the connect fails or times out, the response status is not a success, or the framing’s setup fails — for StreamFraming::MultipartMixed that last case is a 200 whose Content-Type names no usable boundary, which is why a multipart open can fail after a success status. Failures after a successful open arrive as items of the returned stream.

§Stability

Not settled surface — see StreamRequest.