teloxide_core/types/
inline_query_result_location.rs

1use serde::{Deserialize, Serialize};
2
3use crate::types::{InlineKeyboardMarkup, InputMessageContent, LivePeriod};
4
5/// Represents a location on a map.
6///
7/// By default, the location will be sent by the user. Alternatively, you can
8/// use `input_message_content` to send a message with the specified content
9/// instead of the location.
10///
11/// [The official docs](https://core.telegram.org/bots/api#inlinequeryresultlocation).
12#[serde_with::skip_serializing_none]
13#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
14pub struct InlineQueryResultLocation {
15    /// Unique identifier for this result, 1-64 Bytes.
16    pub id: String,
17
18    /// Location latitude in degrees.
19    pub latitude: f64,
20
21    /// Location longitude in degrees.
22    pub longitude: f64,
23
24    /// Location title.
25    pub title: String,
26
27    /// The radius of uncertainty for the location, measured in meters; 0-1500
28    pub horizontal_accuracy: Option<f64>,
29
30    /// Period in seconds for which the location can be updated, should be
31    /// between 60 and 86400, or 0x7FFFFFFF for live locations that can be
32    /// edited indefinitely.
33    pub live_period: Option<LivePeriod>,
34
35    /// For live locations, a direction in which the user is moving, in degrees.
36    /// Must be between 1 and 360 if specified.
37    pub heading: Option<u16>,
38
39    /// For live locations, a maximum distance for proximity alerts about
40    /// approaching another chat member, in meters. Must be between 1 and 100000
41    /// if specified.
42    pub proximity_alert_radius: Option<u32>,
43
44    /// [Inline keyboard] attached to the message.
45    ///
46    /// [Inline keyboard]: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
47    pub reply_markup: Option<InlineKeyboardMarkup>,
48
49    /// Content of the message to be sent instead of the location.
50    pub input_message_content: Option<InputMessageContent>,
51
52    /// Url of the thumbnail for the result.
53    pub thumbnail_url: Option<reqwest::Url>,
54
55    /// Thumbnail width.
56    pub thumbnail_width: Option<u32>,
57
58    /// Thumbnail height.
59    pub thumbnail_height: Option<u32>,
60}
61
62impl InlineQueryResultLocation {
63    pub fn new<S1, S2>(id: S1, title: S2, latitude: f64, longitude: f64) -> Self
64    where
65        S1: Into<String>,
66        S2: Into<String>,
67    {
68        Self {
69            id: id.into(),
70            title: title.into(),
71            latitude,
72            longitude,
73            live_period: None,
74            reply_markup: None,
75            input_message_content: None,
76            thumbnail_url: None,
77            thumbnail_width: None,
78            thumbnail_height: None,
79            horizontal_accuracy: None,
80            heading: None,
81            proximity_alert_radius: None,
82        }
83    }
84
85    pub fn id<S>(mut self, val: S) -> Self
86    where
87        S: Into<String>,
88    {
89        self.id = val.into();
90        self
91    }
92
93    #[must_use]
94    pub fn latitude(mut self, val: f64) -> Self {
95        self.latitude = val;
96        self
97    }
98
99    #[must_use]
100    pub fn longitude(mut self, val: f64) -> Self {
101        self.longitude = val;
102        self
103    }
104
105    pub fn title<S>(mut self, val: S) -> Self
106    where
107        S: Into<String>,
108    {
109        self.title = val.into();
110        self
111    }
112
113    #[must_use]
114    pub fn horizontal_accuracy<S>(mut self, val: f64) -> Self {
115        self.horizontal_accuracy = Some(val);
116        self
117    }
118
119    #[must_use]
120    pub fn live_period(mut self, val: LivePeriod) -> Self {
121        self.live_period = Some(val);
122        self
123    }
124
125    #[must_use]
126    pub fn heading(mut self, val: u16) -> Self {
127        self.heading = Some(val);
128        self
129    }
130
131    #[must_use]
132    pub fn proximity_alert_radius(mut self, val: u32) -> Self {
133        self.proximity_alert_radius = Some(val);
134        self
135    }
136
137    #[must_use]
138    pub fn reply_markup(mut self, val: InlineKeyboardMarkup) -> Self {
139        self.reply_markup = Some(val);
140        self
141    }
142
143    #[must_use]
144    pub fn input_message_content(mut self, val: InputMessageContent) -> Self {
145        self.input_message_content = Some(val);
146        self
147    }
148
149    #[must_use]
150    pub fn thumbnail_url(mut self, val: reqwest::Url) -> Self {
151        self.thumbnail_url = Some(val);
152        self
153    }
154
155    #[must_use]
156    pub fn thumbnail_width(mut self, val: u32) -> Self {
157        self.thumbnail_width = Some(val);
158        self
159    }
160
161    #[must_use]
162    pub fn thumbnail_height(mut self, val: u32) -> Self {
163        self.thumbnail_height = Some(val);
164        self
165    }
166}