telegram_bot_raw/requests/
leave_chat.rs1use crate::requests::*;
2use crate::types::*;
3
4#[derive(Debug, Clone, PartialEq, PartialOrd, Serialize)]
6#[must_use = "requests do nothing unless sent"]
7pub struct LeaveChat {
8 chat_id: ChatRef,
9}
10
11impl Request for LeaveChat {
12 type Type = JsonRequestType<Self>;
13 type Response = JsonTrueToUnitResponse;
14
15 fn serialize(&self) -> Result<HttpRequest, Error> {
16 Self::Type::serialize(RequestUrl::method("leaveChat"), self)
17 }
18}
19
20impl LeaveChat {
21 pub fn new<C>(chat: C) -> Self
22 where
23 C: ToChatRef,
24 {
25 LeaveChat {
26 chat_id: chat.to_chat_ref(),
27 }
28 }
29}
30
31pub trait CanLeaveChat {
33 fn leave(&self) -> LeaveChat;
34}
35
36impl<C> CanLeaveChat for C
37where
38 C: ToChatRef,
39{
40 fn leave(&self) -> LeaveChat {
41 LeaveChat::new(self)
42 }
43}