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