#http #web #stream #axus

reqwest-streams

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

8 releases

0.2.5 Feb 4, 2023
0.2.4 Nov 21, 2022
0.2.0 Jul 31, 2022
0.1.6 Jul 31, 2022

#1816 in Network programming

Download history 16/week @ 2022-12-02 16/week @ 2022-12-09 6/week @ 2022-12-16 3/week @ 2022-12-23 5/week @ 2022-12-30 15/week @ 2023-01-06 25/week @ 2023-01-13 18/week @ 2023-01-20 19/week @ 2023-01-27 27/week @ 2023-02-03 53/week @ 2023-02-10 30/week @ 2023-02-17 5/week @ 2023-02-24 6/week @ 2023-03-03 10/week @ 2023-03-10 53/week @ 2023-03-17

74 downloads per month

Apache-2.0

36KB
779 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.2", 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

~7–14MB
~283K SLoC