Skip to main content

AirLibrary/Client/AirServiceProvider/
DownloadStream.rs

1//! `AirServiceProvider::DownloadStream` - initiate a streaming download.
2//! Wraps [`crate::Client::AirClient::AirClient::DownloadStream`] and
3//! returns the stream wrapper so callers can pump chunks via
4//! `.next().await`.
5
6use std::collections::HashMap;
7
8use crate::{
9	AirError,
10	Client::{AirClient::DownloadStream as DownloadStreamDTO, AirServiceProvider::AirServiceProvider},
11	dev_log,
12};
13
14impl AirServiceProvider {
15	/// Starts a streaming download from `url`. The returned wrapper
16	/// yields [`DownloadStreamDTO::Struct`] items until
17	/// `chunk.completed == true`.
18	pub async fn DownloadStream(
19		&self,
20
21		url:String,
22
23		headers:HashMap<String, String>,
24	) -> Result<DownloadStreamDTO::Struct, AirError> {
25		let RequestID = crate::Utility::GenerateRequestId();
26
27		dev_log!(
28			"grpc",
29			"[AirServiceProvider] DownloadStream (request_id: {}, url: {})",
30			RequestID,
31			url
32		);
33
34		self.client.DownloadStream(RequestID, url, headers).await
35	}
36}