更新 IcalinguaStatus 结构体的方法实现

This commit is contained in:
shenjack 2024-02-25 01:31:56 +08:00
parent 95c2cc377a
commit 03fdcc300b
Signed by: shenjack
GPG Key ID: 7B1134A979775551

View File

@ -47,25 +47,14 @@ impl IcalinguaStatus {
self.online_data = Some(online_data); self.online_data = Some(online_data);
} }
pub fn update_rooms(&mut self, rooms: Vec<Room>) { pub fn update_rooms(&mut self, rooms: Vec<Room>) { self.rooms = Some(rooms); }
self.rooms = Some(rooms);
}
pub fn update_login_status(&mut self, login: bool) { pub fn update_login_status(&mut self, login: bool) { self.login = login; }
self.login = login;
}
pub fn update_config(&mut self, config: IcaConfig) { pub fn update_config(&mut self, config: IcaConfig) { self.config = Some(config); }
self.config = Some(config);
}
pub fn get_online_data() -> &'static OnlineData { pub fn get_online_data() -> &'static OnlineData {
unsafe { unsafe { ClientStatus.online_data.as_ref().expect("online_data should be set") }
ClientStatus
.online_data
.as_ref()
.expect("online_data should be set")
}
} }
pub fn get_config() -> &'static IcaConfig { pub fn get_config() -> &'static IcaConfig {
@ -99,8 +88,5 @@ pub async fn sign_callback(payload: Payload, client: Client) {
let signature: Signature = signing_key.sign(salt.as_slice()); let signature: Signature = signing_key.sign(salt.as_slice());
let sign = signature.to_bytes().to_vec(); let sign = signature.to_bytes().to_vec();
client client.emit("auth", sign).await.expect("Faild to send signin data");
.emit("auth", sign)
.await
.expect("Faild to send signin data");
} }