Cargo tests and formatting security audit

axum streams for Rust

Library provides HTTP response streaming support for axum web framework: - JSON array stream format - JSON lines stream format - CSV stream - Protobuf len-prefixed stream format - Text stream

This type of responses are useful when you are reading huge stream of objects from some source (such as database, file, etc) and want to avoid huge memory allocation.

Quick start

Cargo.toml: toml [dependencies] axum-streams = { version = "0.8", features=["json", "csv", "protobuf", "text"] }

Compatibility matrix

| axum | axum-streams | |------|--------------| | 0.6 | 0.8 | | 0.5 | 0.7 |

Example code: ```rust

[derive(Debug, Clone, Deserialize, Serialize)]

struct MyTestStructure { sometestfield: String }

fn mysourcestream() -> impl Stream { // Simulating a stream with a plain vector and throttling to show how it works stream::iter(vec![ MyTestStructure { sometestfield: "test1".tostring() }; 1000 ]).throttle(std::time::Duration::frommillis(50)) }

async fn testjsonarraystream() -> impl IntoResponse { StreamBodyAs::jsonarray(sourceteststream()) }

async fn testjsonnlstream() -> impl IntoResponse { StreamBodyAs::jsonnl(sourceteststream()) }

async fn testcsvstream() -> impl IntoResponse { StreamBodyAs::csv(sourceteststream()) }

async fn testtextstream() -> impl IntoResponse { StreamBodyAs::text(sourceteststream()) }

```

All examples available at examples directory.

To run example use: ```

cargo run --example json-example --features json

```

Need client support?

There is the same functionality for: - reqwest-streams.

Licence

Apache Software License (ASL)

Author

Abdulla Abdurakhmanov