pub trait JsonStreamRequest {
// Required methods
fn json_array_stream_body<S, T>(self, stream: S) -> RequestBuilder
where T: Serialize + Send + 'static,
S: Stream<Item = T> + Send + 'static;
fn try_json_array_stream_body<S, T, E>(self, stream: S) -> RequestBuilder
where T: Serialize + Send + 'static,
S: Stream<Item = Result<T, E>> + Send + 'static,
E: Into<Box<dyn Error + Send + Sync>> + Send + 'static;
fn json_nl_stream_body<S, T>(self, stream: S) -> RequestBuilder
where T: Serialize + Send + 'static,
S: Stream<Item = T> + Send + 'static;
fn try_json_nl_stream_body<S, T, E>(self, stream: S) -> RequestBuilder
where T: Serialize + Send + 'static,
S: Stream<Item = Result<T, E>> + Send + 'static,
E: Into<Box<dyn Error + Send + Sync>> + Send + 'static;
}Available on crate feature
json only.Expand description
Extension trait for reqwest::RequestBuilder that streams a JSON request body.
The try_ variants take a fallible source stream. See ReqwestStreamBody for the HTTP
caveats that apply to every streamed request body — the redirect one in particular.
Required Methods§
Sourcefn json_array_stream_body<S, T>(self, stream: S) -> RequestBuilder
fn json_array_stream_body<S, T>(self, stream: S) -> RequestBuilder
Streams stream as a JSON array, setting Content-Type: application/json.
use futures::stream;
use reqwest_streams::JsonStreamRequest as _;
use serde::Serialize;
#[derive(Serialize)]
struct MyItem {
field: String,
}
let items = stream::iter(vec![MyItem { field: "value".into() }]);
reqwest::Client::new()
.post("http://localhost:8080/ingest")
.json_array_stream_body(items)
.send()
.await?;Sourcefn try_json_array_stream_body<S, T, E>(self, stream: S) -> RequestBuilder
fn try_json_array_stream_body<S, T, E>(self, stream: S) -> RequestBuilder
Streams a fallible stream as a JSON array.
Sourcefn json_nl_stream_body<S, T>(self, stream: S) -> RequestBuilder
fn json_nl_stream_body<S, T>(self, stream: S) -> RequestBuilder
Streams stream as JSON Lines, setting Content-Type: application/jsonstream.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".