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

reqwest-streams

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

12 unstable releases (4 breaking)

0.5.1 Dec 8, 2023
0.5.0 Dec 8, 2023
0.4.0 Nov 9, 2023
0.3.0 May 22, 2023
0.1.6 Jul 31, 2022

#6 in #streaming-json

Download history 34/week @ 2023-12-22 258/week @ 2023-12-29 17/week @ 2024-01-05 17/week @ 2024-01-12 11/week @ 2024-01-19 50/week @ 2024-01-26 9/week @ 2024-02-02 21/week @ 2024-02-09 6/week @ 2024-02-16 139/week @ 2024-02-23 413/week @ 2024-03-01 177/week @ 2024-03-08 116/week @ 2024-03-15 178/week @ 2024-03-22 179/week @ 2024-03-29 345/week @ 2024-04-05

835 downloads per month
Used in 3 crates

Apache-2.0

39KB
816 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

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.5", features=["json", "csv", "protobuf"] }

Example code:


use reqwest_streams::*;
use futures_util::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–21MB
~287K SLoC