telegram_bot_raw/requests/
get_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 GetChat {
8 chat_id: ChatRef,
9}
10
11impl Request for GetChat {
12 type Type = JsonRequestType<Self>;
13 type Response = JsonIdResponse<Chat>;
14
15 fn serialize(&self) -> Result<HttpRequest, Error> {
16 Self::Type::serialize(RequestUrl::method("getChat"), self)
17 }
18}
19
20impl GetChat {
21 pub fn new<C>(chat: C) -> Self
22 where
23 C: ToChatRef,
24 {
25 GetChat {
26 chat_id: chat.to_chat_ref(),
27 }
28 }
29}
30
31pub trait CanGetChat {
33 fn get_chat(&self) -> GetChat;
34}
35
36impl<C> CanGetChat for C
37where
38 C: ToChatRef,
39{
40 fn get_chat(&self) -> GetChat {
41 GetChat::new(self)
42 }
43}