#[non_exhaustive]pub struct ReqwestStreamOptions {
pub max_obj_len: usize,
pub buf_capacity: usize,
pub on_error: Option<ReqwestStreamErrorHandler>,
pub on_progress: Option<ReqwestStreamProgressHandler>,
pub progress_interval: Option<Duration>,
pub progress_items: Option<u64>,
}arrow or csv or json or protobuf only.Expand description
Options shared by every streaming format.
Build these with ReqwestStreamOptions::new and the setters below rather than with a
struct literal, so that later options can be added without breaking you.
§Note on max_obj_len
Unlike the positional-argument methods, which make you choose a limit, a freshly built
ReqwestStreamOptions does not limit object size — max_obj_len defaults to
usize::MAX. Set it explicitly when reading from a source you do not control.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.max_obj_len: usize§buf_capacity: usize§on_error: Option<ReqwestStreamErrorHandler>§on_progress: Option<ReqwestStreamProgressHandler>§progress_interval: Option<Duration>§progress_items: Option<u64>Implementations§
Source§impl ReqwestStreamOptions
impl ReqwestStreamOptions
pub fn new() -> Self
Sourcepub fn max_obj_len(self, max_obj_len: usize) -> Self
pub fn max_obj_len(self, max_obj_len: usize) -> Self
The maximum size in bytes of a single decoded object.
usize::MAX, the default, means no limit.
Sourcepub fn buf_capacity(self, buf_capacity: usize) -> Self
pub fn buf_capacity(self, buf_capacity: usize) -> Self
The initial capacity of the stream’s decoding buffer.
Sourcepub fn on_error<F>(self, handler: F) -> Self
pub fn on_error<F>(self, handler: F) -> Self
Registers a callback invoked for every error produced while reading the response, covering both transport errors and decoding errors produced by the format itself.
The error is still yielded by the stream; this is purely an observation hook. It does
not replace the tracing feature: when that feature is enabled both the log event and
this callback fire.
Sourcepub fn on_progress<F>(self, handler: F) -> Self
pub fn on_progress<F>(self, handler: F) -> Self
Registers a callback receiving progress snapshots while the response is read: one per reporting interval or item step, plus a final one carrying the totals and how the stream ended (completed, failed, or aborted because the consumer stopped reading).
This is the same accounting the tracing feature reports, exposed for metrics: wire it
to a counter and you get streamed items and bytes without depending on tracing at all.
When the feature is enabled both happen.
The counters are only maintained when someone is listening, so a stream with no
callback and no tracing subscriber interested in reqwest_streams pays nothing.
Sourcepub fn progress_interval(self, interval: Duration) -> Self
pub fn progress_interval(self, interval: Duration) -> Self
Reports progress at most once per interval (one second by default).
Set the field to None directly to report on item steps only.
Sourcepub fn progress_items(self, items: u64) -> Self
pub fn progress_items(self, items: u64) -> Self
Additionally reports progress every items items.
Off by default, and deliberately so: it is a linear step, so a large stream reports a
number of times proportional to its size. Prefer Self::progress_interval unless you
specifically want item-granular checkpoints.