axum-streams 0.25.0

HTTP body streaming support for Axum: json/csv/protobuf/arrow/txt
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
use crate::StreamBodyAsOptions;
use futures::stream::BoxStream;
use http::HeaderMap;

pub trait StreamingFormat<T> {
    fn to_bytes_stream<'a, 'b>(
        &'a self,
        stream: BoxStream<'b, Result<T, axum::Error>>,
        options: &'a StreamBodyAsOptions,
    ) -> BoxStream<'b, Result<axum::body::Bytes, axum::Error>>;

    fn http_response_headers(&self, options: &StreamBodyAsOptions) -> Option<HeaderMap>;
}