Skip to main content

AirLibrary/Client/AirServiceProvider/
CheckForUpdates.rs

1//! `AirServiceProvider::CheckForUpdates` - probe the Air daemon for an
2//! available update. Wraps
3//! [`crate::Client::AirClient::AirClient::CheckForUpdates`] and collapses
4//! `update_available == false` into `Ok(None)` so callers can pattern-
5//! match `Some(info)` for the live-update case.
6
7use crate::{
8	AirError,
9	Client::{AirClient::UpdateInfo, AirServiceProvider::AirServiceProvider},
10	dev_log,
11};
12
13impl AirServiceProvider {
14	/// Checks for an available update on the given channel
15	/// (`"stable"` / `"beta"` / `"nightly"`).
16	///
17	/// Returns `Ok(Some(info))` when an update is offered and
18	/// `Ok(None)` when the daemon reports no update.
19	pub async fn CheckForUpdates(
20		&self,
21
22		current_version:String,
23
24		channel:String,
25	) -> Result<Option<UpdateInfo::Struct>, AirError> {
26		let RequestID = crate::Utility::GenerateRequestId();
27
28		dev_log!("grpc", "[AirServiceProvider] CheckForUpdates (request_id: {})", RequestID);
29
30		let Info = self.client.CheckForUpdates(RequestID, current_version, channel).await?;
31
32		if Info.update_available { Ok(Some(Info)) } else { Ok(None) }
33	}
34}