1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
use crate::sys;
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub enum Status {
DoNotDisturb,
Idle,
Offline,
Online,
Undefined(sys::EDiscordStatus),
}
impl From<sys::EDiscordStatus> for Status {
fn from(source: sys::EDiscordStatus) -> Self {
match source {
sys::DiscordStatus_DoNotDisturb => Self::DoNotDisturb,
sys::DiscordStatus_Idle => Self::Idle,
sys::DiscordStatus_Offline => Self::Offline,
sys::DiscordStatus_Online => Self::Online,
_ => Self::Undefined(source),
}
}
}
impl std::fmt::Display for Status {
fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
fmt,
"{}",
match self {
Self::DoNotDisturb => "do not disturb",
Self::Idle => "idle",
Self::Offline => "offline",
Self::Online => "online",
Self::Undefined(n) => return write!(fmt, "undefined status ({})", n),
}
)
}
}