Mountain/IPC/WindAirCommands/
AirClientWrapper.rs1#![allow(non_snake_case)]
2
3use crate::{Air::AirClient as AirClientModule, dev_log};
8
9#[derive(Debug, Clone)]
10pub struct Struct {
11 pub(super) client:AirClientModule::AirClient,
12}
13
14impl Struct {
15 pub async fn new(address:String) -> Result<Self, String> {
16 dev_log!("grpc", "[WindAirCommands] Connecting to Air daemon at: {}", address);
17
18 let client = AirClientModule::AirClient::new(&address)
19 .await
20 .map_err(|e| format!("Failed to connect to Air daemon: {:?}", e))?;
21
22 dev_log!("grpc", "[WindAirCommands] Successfully connected to Air daemon");
23
24 Ok(Self { client })
25 }
26
27 pub async fn reconnect(&mut self, address:String) -> Result<(), String> {
28 dev_log!("grpc", "[WindAirCommands] Reconnecting to Air daemon at: {}", address);
29
30 let client = AirClientModule::AirClient::new(&address)
31 .await
32 .map_err(|e| format!("Failed to reconnect to Air daemon: {:?}", e))?;
33
34 self.client = client;
35
36 dev_log!("grpc", "[WindAirCommands] Successfully reconnected to Air daemon");
37
38 Ok(())
39 }
40}