telegram_bot_async_raw/requests/
get_chat_members_count.rs

1use crate::{requests::*, types::*};
2
3/// Use this method to get the number of members in a chat.
4#[derive(Debug, Clone, PartialEq, PartialOrd, Serialize)]
5#[must_use = "requests do nothing unless sent"]
6pub struct GetChatMembersCount {
7    chat_id: ChatRef,
8}
9
10impl Request for GetChatMembersCount {
11    type Type = JsonRequestType<Self>;
12    type Response = JsonIdResponse<Integer>;
13
14    fn serialize(&self) -> Result<HttpRequest, Error> {
15        Self::Type::serialize(RequestUrl::method("getChatMembersCount"), self)
16    }
17}
18
19impl GetChatMembersCount {
20    pub fn new<C>(chat: C) -> Self
21    where
22        C: ToChatRef,
23    {
24        GetChatMembersCount {
25            chat_id: chat.to_chat_ref(),
26        }
27    }
28}
29
30/// Get the number of members in a chat.
31pub trait CanGetChatMembersCount {
32    fn get_members_count(&self) -> GetChatMembersCount;
33}
34
35impl<C> CanGetChatMembersCount for C
36where
37    C: ToChatRef,
38{
39    fn get_members_count(&self) -> GetChatMembersCount {
40        GetChatMembersCount::new(self)
41    }
42}