Skip to main content

AirLibrary/Client/AirServiceProvider/
DownloadFile.rs

1//! `AirServiceProvider::DownloadFile` - generic URL download routed
2//! through Air. Wraps
3//! [`crate::Client::AirClient::AirClient::DownloadFile`] with an empty
4//! header map.
5
6use std::collections::HashMap;
7
8use crate::{
9	AirError,
10	Client::{AirClient::FileInfo, AirServiceProvider::AirServiceProvider},
11	dev_log,
12};
13
14impl AirServiceProvider {
15	/// Downloads `url` to `destination_path`. The optional `checksum`
16	/// is forwarded for server-side verification; an empty string
17	/// skips verification.
18	pub async fn DownloadFile(
19		&self,
20
21		url:String,
22
23		destination_path:String,
24
25		checksum:String,
26	) -> Result<FileInfo::Struct, AirError> {
27		let RequestID = crate::Utility::GenerateRequestId();
28
29		dev_log!("grpc", "[AirServiceProvider] DownloadFile (request_id: {})", RequestID);
30
31		self.client
32			.DownloadFile(RequestID, url, destination_path, checksum, HashMap::new())
33			.await
34	}
35}