Module stream

Module stream 

Source
Expand description

Streaming response types for RustAPI

This module provides types for streaming response bodies.

§Example

use rustapi_core::stream::StreamBody;
use futures_util::stream;
use bytes::Bytes;

async fn stream_data() -> StreamBody<impl Stream<Item = Result<Bytes, std::convert::Infallible>>> {
    let stream = stream::iter(vec![
        Ok(Bytes::from("chunk 1")),
        Ok(Bytes::from("chunk 2")),
    ]);
    StreamBody::new(stream)
}

Structs§

StreamBody
A streaming body wrapper for HTTP responses

Functions§

stream_from_iter
Helper function to create a streaming body from an iterator of byte chunks
stream_from_strings
Helper function to create a streaming body from a string iterator