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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
use std::fmt;
use serde::de;
use serde::de::{Deserialize, Deserializer, Visitor};
use crate::types::*;
#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
pub enum ChatMemberStatus {
Creator,
Administrator,
Member,
Left,
Kicked,
#[doc(hidden)]
Unknown(String),
}
impl<'de> Deserialize<'de> for ChatMemberStatus {
fn deserialize<D>(deserializer: D) -> Result<ChatMemberStatus, D::Error>
where
D: Deserializer<'de>,
{
struct ChatMemberStatusVisitor;
use self::ChatMemberStatus::*;
impl<'de> Visitor<'de> for ChatMemberStatusVisitor {
type Value = ChatMemberStatus;
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
formatter.write_str("creator | administrator | member | left | kicked")
}
fn visit_str<E>(self, value: &str) -> Result<ChatMemberStatus, E>
where
E: de::Error,
{
Ok(match value {
"creator" => Creator,
"administrator" => Administrator,
"member" => Member,
"left" => Left,
"kicked" => Kicked,
_unknown => Unknown(value.to_string()),
})
}
}
deserializer.deserialize_str(ChatMemberStatusVisitor)
}
}
#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash, Deserialize)]
pub struct ChatMember {
pub user: User,
pub status: ChatMemberStatus,
pub until_date: Option<Integer>,
pub can_be_edited: Option<bool>,
pub can_change_info: Option<bool>,
pub can_post_messages: Option<bool>,
pub can_edit_messages: Option<bool>,
pub can_delete_messages: Option<bool>,
pub can_invite_users: Option<bool>,
pub can_restrict_members: Option<bool>,
pub can_pin_messages: Option<bool>,
pub can_promote_members: Option<bool>,
pub can_send_messages: Option<bool>,
pub can_send_media_messages: Option<bool>,
pub can_send_other_messages: Option<bool>,
pub can_add_web_page_previews: Option<bool>,
}