nifi_rust_client/streaming.rs
1#![deny(missing_docs)]
2
3//! Streaming byte responses for endpoints returning unbounded binary
4//! payloads (provenance content, flowfile content, NAR/asset downloads).
5//!
6//! Every generated endpoint whose OpenAPI response body is
7//! `application/octet-stream` or `*/*` ships in two flavors:
8//!
9//! - Buffered: `fn ...() -> Result<Vec<u8>, NifiError>`.
10//! - Streaming: `fn ..._stream() -> Result<BytesStream, NifiError>`.
11//!
12//! Use the streaming variant when the response may be large enough
13//! that buffering into a `Vec<u8>` is undesirable.
14//!
15//! Retry semantics: the initial request (status-line exchange) is
16//! retried via the configured `AuthProvider` and `RetryPolicy` just
17//! like any other request. Once the stream has started producing
18//! chunks, transport errors terminate the stream — they are not
19//! retried.
20//!
21//! To adapt to `tokio::io::AsyncRead`, wrap the stream with
22//! `tokio_util::io::StreamReader`.
23
24use std::pin::Pin;
25
26/// A stream of [`bytes::Bytes`] chunks delivered by a NiFi binary-download
27/// endpoint. Each item is a chunk of the HTTP response body.
28pub type BytesStream =
29 Pin<Box<dyn futures_core::Stream<Item = Result<bytes::Bytes, crate::NifiError>> + Send>>;