Crates.io | reqwest-streams |
lib.rs | reqwest-streams |
version | 0.8.1 |
source | src |
created_at | 2022-07-31 13:40:40.19788 |
updated_at | 2024-11-07 16:17:35.588921 |
description | HTTP body streaming support for reqwest: JSON/CSV/Protobuf and others |
homepage | https://github.com/abdolence/reqwest-streams-rs |
repository | https://github.com/abdolence/reqwest-streams-rs |
max_upload_size | |
id | 636146 |
size | 119,802 |
Library provides HTTP response streaming support for reqwest:
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.
Cargo.toml:
[dependencies]
reqwest-streams = { version = "0.7", 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
There is the same functionality:
Apache Software License (ASL)
Abdulla Abdurakhmanov