wrap_stream

Function wrap_stream 

Source
pub fn wrap_stream<S, O, E>(stream: S) -> BoxBody
where S: Stream<Item = Result<O, E>> + Send + 'static, O: Into<Bytes> + 'static, E: Into<Box<dyn StdError + Send + Sync>> + 'static,
Expand description

Wrap a stream of byte chunks into a BoxBody.

This is used for event streaming support. The stream should produce Result<O, E> where O can be converted into Bytes and E can be converted into an error.

In hyper 0.x, Body::wrap_stream was available directly on the body type. In hyper 1.x, the stream feature was removed, and the official approach is to use http_body_util::StreamBody to convert streams into bodies, which is what this function provides as a convenient wrapper.

For scenarios requiring Sync (e.g., lambda handlers), use wrap_stream_sync instead.