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
use serde::{Deserialize, Serialize};
/// Represents update types to subscribe with [`Webhook`] or [`Polling`].
///
/// [`Webhook`]: ../../event_loop/struct.Webhook.html
/// [`Polling`]: ../../event_loop/struct.Polling.html
#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
// todo: #[non_exhaustive]
pub enum Updates {
/// Handles chat messages of any kind.
Message,
/// Handles chat message edits.
EditedMessage,
/// Handles channel posts of any kind.
ChannelPost,
/// Handles channel post edits.
EditedChannelPost,
/// Handles inline queries.
InlineQuery,
/// Handles chosen inline results.
ChosenInlineResult,
/// Handles inline button clicks.
CallbackQuery,
/// Handles shpping query.
ShippingQuery,
/// Handles pre-checkout query.
PreCheckoutQuery,
/// Handles poll state updates.
Poll,
}
impl Updates {
/// Checks if `self` is `Message`.
pub fn is_message(self) -> bool {
self == Updates::Message
}
/// Checks if `self` is `EditedMessage`.
pub fn is_edited_message(self) -> bool {
self == Updates::EditedMessage
}
/// Checks if `self` is ChanelPost``.
pub fn is_channel_post(self) -> bool {
self == Updates::ChannelPost
}
/// Checks if `self` is `EditedChannelPost`.
pub fn is_edited_channel_post(self) -> bool {
self == Updates::EditedChannelPost
}
/// Checks if `self` is `InlineQuery`.
pub fn is_inline_query(self) -> bool {
self == Updates::InlineQuery
}
/// Checks if `self` is `ChosenInlineResult`.
pub fn is_chosen_inline_result(self) -> bool {
self == Updates::ChosenInlineResult
}
/// Checks if `self` is `CallbackQuery`.
pub fn is_callback_query(self) -> bool {
self == Updates::CallbackQuery
}
/// Checks if `self` is `ShippingQuery`.
pub fn is_shipping_query(self) -> bool {
self == Updates::ShippingQuery
}
/// Checks if `self` is `PreCheckoutQuery`.
pub fn is_pre_checkout_query(self) -> bool {
self == Updates::PreCheckoutQuery
}
/// Checks if `self` is `Poll`.
pub fn is_poll(self) -> bool {
self == Updates::Poll
}
}