Skip to main content

stream

Function stream 

Source
pub fn stream<S, B, E>(stream: S) -> impl Reply
where S: Stream<Item = Result<B, E>> + Send + Sync + 'static, B: Into<Bytes>, E: Into<Box<dyn Error + Send + Sync>> + Send + 'static,
Expand description

Converts a Stream of data chunks into a reply.

ยงExample

use warp::Filter;
use futures_util::stream;
use bytes::Bytes;

let route = warp::any().map(|| {
    let chunks = vec![Ok::<_, std::io::Error>(Bytes::from("hello"))];
    warp::reply::stream(stream::iter(chunks))
});