#stream #http-response #http #web #streaming-json #json-array #axus

reqwest-streams

HTTP body streaming support for reqwest: JSON/CSV/Protobuf and others

13 unstable releases (5 breaking)

0.6.0 Jun 6, 2024
0.5.1 Dec 8, 2023
0.4.0 Nov 9, 2023
0.3.0 May 22, 2023
0.1.6 Jul 31, 2022

#1 in #json-array

Download history 413/week @ 2024-02-26 219/week @ 2024-03-04 159/week @ 2024-03-11 94/week @ 2024-03-18 183/week @ 2024-03-25 226/week @ 2024-04-01 432/week @ 2024-04-08 249/week @ 2024-04-15 228/week @ 2024-04-22 231/week @ 2024-04-29 319/week @ 2024-05-06 528/week @ 2024-05-13 415/week @ 2024-05-20 497/week @ 2024-05-27 660/week @ 2024-06-03 420/week @ 2024-06-10

1,994 downloads per month
Used in 3 crates

Apache-2.0

45KB
971 lines

Cargo tests and formatting security audit

reqwest streams for Rust

Library provides HTTP response streaming support for reqwest:

  • JSON array stream format
  • JSON lines stream format
  • CSV stream
  • Protobuf len-prefixed stream format
  • Arrow IPC stream format

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:

[dependencies]
reqwest-streams = { version = "0.6", features=["json", "csv", "protobuf", "arrow"] }

Example code:


use reqwest_streams::*;
use futures::stream::BoxStream;
use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Deserialize)]
struct MyTestStructure {
    some_test_field: String
}

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {

    let _stream = reqwest::get("http://localhost:8080/json-array")
        .await?
        .json_array_stream::<MyTestStructure>(1024);

    Ok(())
}

All examples available in examples directory.

To run example use:

# cargo run --example json-stream

Need server support?

There is the same functionality:

Licence

Apache Software License (ASL)

Author

Abdulla Abdurakhmanov

Dependencies

~6–20MB
~295K SLoC