[Clean]
This commit is contained in:
parent
6dd479982d
commit
a6c986d56b
2 changed files with 21 additions and 27 deletions
|
|
@ -1,33 +1,27 @@
|
|||
#[derive(Clone, Copy)]
|
||||
#[allow(non_camel_case_types)]
|
||||
use strum::IntoEnumIterator;
|
||||
use strum_macros::EnumIter;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, EnumIter, Eq)]
|
||||
#[allow(unused)]
|
||||
pub enum UserStatus {
|
||||
online,
|
||||
do_not_disturb,
|
||||
wc,
|
||||
away,
|
||||
user_offline,
|
||||
iota_offline,
|
||||
Online,
|
||||
PhoneOnline,
|
||||
Away,
|
||||
DoNotDisturb,
|
||||
UserOffline,
|
||||
IotaOffline,
|
||||
}
|
||||
#[allow(unused)]
|
||||
impl UserStatus {
|
||||
pub fn to_string(self) -> String {
|
||||
match self {
|
||||
UserStatus::online => "online".to_string(),
|
||||
UserStatus::do_not_disturb => "do_not_disturb".to_string(),
|
||||
UserStatus::wc => "wc".to_string(),
|
||||
UserStatus::away => "away".to_string(),
|
||||
UserStatus::user_offline => "user_offline".to_string(),
|
||||
UserStatus::iota_offline => "iota_offline".to_string(),
|
||||
}
|
||||
pub fn to_string(&self) -> String {
|
||||
format!("{:?}", self)
|
||||
}
|
||||
pub fn from_string(status_str: &str) -> Result<Self, String> {
|
||||
match status_str.to_lowercase().as_str() {
|
||||
"online" => Ok(UserStatus::online),
|
||||
"do_not_disturb" => Ok(UserStatus::do_not_disturb),
|
||||
"wc" => Ok(UserStatus::wc),
|
||||
"away" => Ok(UserStatus::away),
|
||||
"user_offline" => Ok(UserStatus::user_offline),
|
||||
"iota_offline" => Ok(UserStatus::iota_offline),
|
||||
_ => Err(format!("Invalid user status: {}", status_str)),
|
||||
pub fn from_str(s: &str) -> Option<UserStatus> {
|
||||
for sel in UserStatus::iter() {
|
||||
if &sel.to_string() == s {
|
||||
return Some(sel);
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -258,7 +258,7 @@ impl OmegaConnection {
|
|||
break;
|
||||
}
|
||||
cloned_self.send_ping().await;
|
||||
sleep(Duration::from_secs(1)).await;
|
||||
sleep(Duration::from_secs(5)).await;
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue