telegram_bot_raw/requests/
stop_message_live_location.rs1use crate::requests::*;
2use crate::types::*;
3
4#[derive(Debug, Clone, PartialEq, PartialOrd, Serialize)]
7#[must_use = "requests do nothing unless sent"]
8pub struct StopMessageLiveLocation {
9 chat_id: ChatRef,
10 message_id: MessageId,
11 #[serde(skip_serializing_if = "Option::is_none")]
12 reply_markup: Option<ReplyMarkup>,
13}
14
15impl Request for StopMessageLiveLocation {
16 type Type = JsonRequestType<Self>;
17 type Response = JsonIdResponse<Message>;
18
19 fn serialize(&self) -> Result<HttpRequest, Error> {
20 Self::Type::serialize(RequestUrl::method("stopMessageLiveLocation"), self)
21 }
22}
23
24impl StopMessageLiveLocation {
25 pub fn new<C, M>(chat: C, message_id: M) -> Self
26 where
27 C: ToChatRef,
28 M: ToMessageId,
29 {
30 StopMessageLiveLocation {
31 chat_id: chat.to_chat_ref(),
32 message_id: message_id.to_message_id(),
33 reply_markup: None,
34 }
35 }
36
37 pub fn reply_markup<R>(&mut self, reply_markup: R) -> &mut Self
38 where
39 R: Into<ReplyMarkup>,
40 {
41 self.reply_markup = Some(reply_markup.into());
42 self
43 }
44}
45
46pub trait CanStopMessageLiveLocation {
48 fn stop_live_location(&self) -> StopMessageLiveLocation;
49}
50
51impl<M> CanStopMessageLiveLocation for M
52where
53 M: ToMessageId + ToSourceChat,
54{
55 fn stop_live_location(&self) -> StopMessageLiveLocation {
56 StopMessageLiveLocation::new(self.to_source_chat(), self.to_message_id())
57 }
58}