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