AirLibrary/Client/AirClient/
ApplyUpdate.rs1use tonic::Request;
9
10use crate::{AirError, Client::AirClient::AirClient, Vine::Generated::air::ApplyUpdateRequest, dev_log};
11
12impl AirClient {
13 pub async fn ApplyUpdate(&self, request_id:String, version:String, update_path:String) -> Result<(), AirError> {
21 dev_log!("grpc", "[AirClient] Applying update version: {}", version);
22
23 let RequestPayload = ApplyUpdateRequest { request_id, version, update_path };
24
25 let Client = self
26 .Client()
27 .ok_or_else(|| AirError::Network("Air client not initialized".to_string()))?;
28
29 let mut ClientGuard = Client.lock().await;
30
31 match ClientGuard.apply_update(Request::new(RequestPayload)).await {
32 Ok(Response) => {
33 let Response = Response.into_inner();
34
35 if Response.success {
36 dev_log!("grpc", "[AirClient] Update applied successfully");
37
38 Ok(())
39 } else {
40 dev_log!("grpc", "error: [AirClient] Update application failed: {}", Response.error);
41
42 Err(AirError::Internal(Response.error))
43 }
44 },
45
46 Err(Status) => {
47 dev_log!("grpc", "error: [AirClient] Apply update RPC error: {}", Status);
48
49 Err(AirError::Network(format!("Apply update RPC error: {}", Status)))
50 },
51 }
52 }
53}