rust_tdlib/types/
inline_query_result.rs

1use crate::errors::Result;
2use crate::types::*;
3use uuid::Uuid;
4
5use std::fmt::Debug;
6
7/// Represents a single result of an inline query
8pub trait TDInlineQueryResult: Debug + RObject {}
9
10/// Represents a single result of an inline query
11#[derive(Debug, Clone, Deserialize, Serialize, Default)]
12#[serde(tag = "@type")]
13pub enum InlineQueryResult {
14    #[doc(hidden)]
15    #[default]
16    _Default,
17    /// Represents an animation file
18    #[serde(rename = "inlineQueryResultAnimation")]
19    Animation(InlineQueryResultAnimation),
20    /// Represents a link to an article or web page
21    #[serde(rename = "inlineQueryResultArticle")]
22    Article(InlineQueryResultArticle),
23    /// Represents an audio file
24    #[serde(rename = "inlineQueryResultAudio")]
25    Audio(InlineQueryResultAudio),
26    /// Represents a user contact
27    #[serde(rename = "inlineQueryResultContact")]
28    Contact(InlineQueryResultContact),
29    /// Represents a document
30    #[serde(rename = "inlineQueryResultDocument")]
31    Document(InlineQueryResultDocument),
32    /// Represents information about a game
33    #[serde(rename = "inlineQueryResultGame")]
34    Game(Box<InlineQueryResultGame>),
35    /// Represents a point on the map
36    #[serde(rename = "inlineQueryResultLocation")]
37    Location(InlineQueryResultLocation),
38    /// Represents a photo
39    #[serde(rename = "inlineQueryResultPhoto")]
40    Photo(InlineQueryResultPhoto),
41    /// Represents a sticker
42    #[serde(rename = "inlineQueryResultSticker")]
43    Sticker(InlineQueryResultSticker),
44    /// Represents information about a venue
45    #[serde(rename = "inlineQueryResultVenue")]
46    Venue(InlineQueryResultVenue),
47    /// Represents a video
48    #[serde(rename = "inlineQueryResultVideo")]
49    Video(Box<InlineQueryResultVideo>),
50    /// Represents a voice note
51    #[serde(rename = "inlineQueryResultVoiceNote")]
52    VoiceNote(InlineQueryResultVoiceNote),
53}
54
55impl RObject for InlineQueryResult {
56    #[doc(hidden)]
57    fn extra(&self) -> Option<&str> {
58        match self {
59            InlineQueryResult::Animation(t) => t.extra(),
60            InlineQueryResult::Article(t) => t.extra(),
61            InlineQueryResult::Audio(t) => t.extra(),
62            InlineQueryResult::Contact(t) => t.extra(),
63            InlineQueryResult::Document(t) => t.extra(),
64            InlineQueryResult::Game(t) => t.extra(),
65            InlineQueryResult::Location(t) => t.extra(),
66            InlineQueryResult::Photo(t) => t.extra(),
67            InlineQueryResult::Sticker(t) => t.extra(),
68            InlineQueryResult::Venue(t) => t.extra(),
69            InlineQueryResult::Video(t) => t.extra(),
70            InlineQueryResult::VoiceNote(t) => t.extra(),
71
72            _ => None,
73        }
74    }
75    #[doc(hidden)]
76    fn client_id(&self) -> Option<i32> {
77        match self {
78            InlineQueryResult::Animation(t) => t.client_id(),
79            InlineQueryResult::Article(t) => t.client_id(),
80            InlineQueryResult::Audio(t) => t.client_id(),
81            InlineQueryResult::Contact(t) => t.client_id(),
82            InlineQueryResult::Document(t) => t.client_id(),
83            InlineQueryResult::Game(t) => t.client_id(),
84            InlineQueryResult::Location(t) => t.client_id(),
85            InlineQueryResult::Photo(t) => t.client_id(),
86            InlineQueryResult::Sticker(t) => t.client_id(),
87            InlineQueryResult::Venue(t) => t.client_id(),
88            InlineQueryResult::Video(t) => t.client_id(),
89            InlineQueryResult::VoiceNote(t) => t.client_id(),
90
91            _ => None,
92        }
93    }
94}
95
96impl InlineQueryResult {
97    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
98        Ok(serde_json::from_str(json.as_ref())?)
99    }
100    #[doc(hidden)]
101    pub fn _is_default(&self) -> bool {
102        matches!(self, InlineQueryResult::_Default)
103    }
104}
105
106impl AsRef<InlineQueryResult> for InlineQueryResult {
107    fn as_ref(&self) -> &InlineQueryResult {
108        self
109    }
110}
111
112/// Represents an animation file
113#[derive(Debug, Clone, Default, Serialize, Deserialize)]
114pub struct InlineQueryResultAnimation {
115    #[doc(hidden)]
116    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
117    extra: Option<String>,
118    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
119    client_id: Option<i32>,
120    /// Unique identifier of the query result
121
122    #[serde(default)]
123    id: String,
124    /// Animation file
125    animation: Animation,
126    /// Animation title
127
128    #[serde(default)]
129    title: String,
130}
131
132impl RObject for InlineQueryResultAnimation {
133    #[doc(hidden)]
134    fn extra(&self) -> Option<&str> {
135        self.extra.as_deref()
136    }
137    #[doc(hidden)]
138    fn client_id(&self) -> Option<i32> {
139        self.client_id
140    }
141}
142
143impl TDInlineQueryResult for InlineQueryResultAnimation {}
144
145impl InlineQueryResultAnimation {
146    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
147        Ok(serde_json::from_str(json.as_ref())?)
148    }
149    pub fn builder() -> InlineQueryResultAnimationBuilder {
150        let mut inner = InlineQueryResultAnimation::default();
151        inner.extra = Some(Uuid::new_v4().to_string());
152
153        InlineQueryResultAnimationBuilder { inner }
154    }
155
156    pub fn id(&self) -> &String {
157        &self.id
158    }
159
160    pub fn animation(&self) -> &Animation {
161        &self.animation
162    }
163
164    pub fn title(&self) -> &String {
165        &self.title
166    }
167}
168
169#[doc(hidden)]
170pub struct InlineQueryResultAnimationBuilder {
171    inner: InlineQueryResultAnimation,
172}
173
174#[deprecated]
175pub type RTDInlineQueryResultAnimationBuilder = InlineQueryResultAnimationBuilder;
176
177impl InlineQueryResultAnimationBuilder {
178    pub fn build(&self) -> InlineQueryResultAnimation {
179        self.inner.clone()
180    }
181
182    pub fn id<T: AsRef<str>>(&mut self, id: T) -> &mut Self {
183        self.inner.id = id.as_ref().to_string();
184        self
185    }
186
187    pub fn animation<T: AsRef<Animation>>(&mut self, animation: T) -> &mut Self {
188        self.inner.animation = animation.as_ref().clone();
189        self
190    }
191
192    pub fn title<T: AsRef<str>>(&mut self, title: T) -> &mut Self {
193        self.inner.title = title.as_ref().to_string();
194        self
195    }
196}
197
198impl AsRef<InlineQueryResultAnimation> for InlineQueryResultAnimation {
199    fn as_ref(&self) -> &InlineQueryResultAnimation {
200        self
201    }
202}
203
204impl AsRef<InlineQueryResultAnimation> for InlineQueryResultAnimationBuilder {
205    fn as_ref(&self) -> &InlineQueryResultAnimation {
206        &self.inner
207    }
208}
209
210/// Represents a link to an article or web page
211#[derive(Debug, Clone, Default, Serialize, Deserialize)]
212pub struct InlineQueryResultArticle {
213    #[doc(hidden)]
214    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
215    extra: Option<String>,
216    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
217    client_id: Option<i32>,
218    /// Unique identifier of the query result
219
220    #[serde(default)]
221    id: String,
222    /// URL of the result, if it exists
223
224    #[serde(default)]
225    url: String,
226    /// True, if the URL must be not shown
227
228    #[serde(default)]
229    hide_url: bool,
230    /// Title of the result
231
232    #[serde(default)]
233    title: String,
234    /// Represents a link to an article or web page
235
236    #[serde(default)]
237    description: String,
238    /// Result thumbnail in JPEG format; may be null
239    thumbnail: Option<Thumbnail>,
240}
241
242impl RObject for InlineQueryResultArticle {
243    #[doc(hidden)]
244    fn extra(&self) -> Option<&str> {
245        self.extra.as_deref()
246    }
247    #[doc(hidden)]
248    fn client_id(&self) -> Option<i32> {
249        self.client_id
250    }
251}
252
253impl TDInlineQueryResult for InlineQueryResultArticle {}
254
255impl InlineQueryResultArticle {
256    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
257        Ok(serde_json::from_str(json.as_ref())?)
258    }
259    pub fn builder() -> InlineQueryResultArticleBuilder {
260        let mut inner = InlineQueryResultArticle::default();
261        inner.extra = Some(Uuid::new_v4().to_string());
262
263        InlineQueryResultArticleBuilder { inner }
264    }
265
266    pub fn id(&self) -> &String {
267        &self.id
268    }
269
270    pub fn url(&self) -> &String {
271        &self.url
272    }
273
274    pub fn hide_url(&self) -> bool {
275        self.hide_url
276    }
277
278    pub fn title(&self) -> &String {
279        &self.title
280    }
281
282    pub fn description(&self) -> &String {
283        &self.description
284    }
285
286    pub fn thumbnail(&self) -> &Option<Thumbnail> {
287        &self.thumbnail
288    }
289}
290
291#[doc(hidden)]
292pub struct InlineQueryResultArticleBuilder {
293    inner: InlineQueryResultArticle,
294}
295
296#[deprecated]
297pub type RTDInlineQueryResultArticleBuilder = InlineQueryResultArticleBuilder;
298
299impl InlineQueryResultArticleBuilder {
300    pub fn build(&self) -> InlineQueryResultArticle {
301        self.inner.clone()
302    }
303
304    pub fn id<T: AsRef<str>>(&mut self, id: T) -> &mut Self {
305        self.inner.id = id.as_ref().to_string();
306        self
307    }
308
309    pub fn url<T: AsRef<str>>(&mut self, url: T) -> &mut Self {
310        self.inner.url = url.as_ref().to_string();
311        self
312    }
313
314    pub fn hide_url(&mut self, hide_url: bool) -> &mut Self {
315        self.inner.hide_url = hide_url;
316        self
317    }
318
319    pub fn title<T: AsRef<str>>(&mut self, title: T) -> &mut Self {
320        self.inner.title = title.as_ref().to_string();
321        self
322    }
323
324    pub fn description<T: AsRef<str>>(&mut self, description: T) -> &mut Self {
325        self.inner.description = description.as_ref().to_string();
326        self
327    }
328
329    pub fn thumbnail<T: AsRef<Thumbnail>>(&mut self, thumbnail: T) -> &mut Self {
330        self.inner.thumbnail = Some(thumbnail.as_ref().clone());
331        self
332    }
333}
334
335impl AsRef<InlineQueryResultArticle> for InlineQueryResultArticle {
336    fn as_ref(&self) -> &InlineQueryResultArticle {
337        self
338    }
339}
340
341impl AsRef<InlineQueryResultArticle> for InlineQueryResultArticleBuilder {
342    fn as_ref(&self) -> &InlineQueryResultArticle {
343        &self.inner
344    }
345}
346
347/// Represents an audio file
348#[derive(Debug, Clone, Default, Serialize, Deserialize)]
349pub struct InlineQueryResultAudio {
350    #[doc(hidden)]
351    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
352    extra: Option<String>,
353    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
354    client_id: Option<i32>,
355    /// Unique identifier of the query result
356
357    #[serde(default)]
358    id: String,
359    /// Audio file
360    audio: Audio,
361}
362
363impl RObject for InlineQueryResultAudio {
364    #[doc(hidden)]
365    fn extra(&self) -> Option<&str> {
366        self.extra.as_deref()
367    }
368    #[doc(hidden)]
369    fn client_id(&self) -> Option<i32> {
370        self.client_id
371    }
372}
373
374impl TDInlineQueryResult for InlineQueryResultAudio {}
375
376impl InlineQueryResultAudio {
377    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
378        Ok(serde_json::from_str(json.as_ref())?)
379    }
380    pub fn builder() -> InlineQueryResultAudioBuilder {
381        let mut inner = InlineQueryResultAudio::default();
382        inner.extra = Some(Uuid::new_v4().to_string());
383
384        InlineQueryResultAudioBuilder { inner }
385    }
386
387    pub fn id(&self) -> &String {
388        &self.id
389    }
390
391    pub fn audio(&self) -> &Audio {
392        &self.audio
393    }
394}
395
396#[doc(hidden)]
397pub struct InlineQueryResultAudioBuilder {
398    inner: InlineQueryResultAudio,
399}
400
401#[deprecated]
402pub type RTDInlineQueryResultAudioBuilder = InlineQueryResultAudioBuilder;
403
404impl InlineQueryResultAudioBuilder {
405    pub fn build(&self) -> InlineQueryResultAudio {
406        self.inner.clone()
407    }
408
409    pub fn id<T: AsRef<str>>(&mut self, id: T) -> &mut Self {
410        self.inner.id = id.as_ref().to_string();
411        self
412    }
413
414    pub fn audio<T: AsRef<Audio>>(&mut self, audio: T) -> &mut Self {
415        self.inner.audio = audio.as_ref().clone();
416        self
417    }
418}
419
420impl AsRef<InlineQueryResultAudio> for InlineQueryResultAudio {
421    fn as_ref(&self) -> &InlineQueryResultAudio {
422        self
423    }
424}
425
426impl AsRef<InlineQueryResultAudio> for InlineQueryResultAudioBuilder {
427    fn as_ref(&self) -> &InlineQueryResultAudio {
428        &self.inner
429    }
430}
431
432/// Represents a user contact
433#[derive(Debug, Clone, Default, Serialize, Deserialize)]
434pub struct InlineQueryResultContact {
435    #[doc(hidden)]
436    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
437    extra: Option<String>,
438    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
439    client_id: Option<i32>,
440    /// Unique identifier of the query result
441
442    #[serde(default)]
443    id: String,
444    /// A user contact
445    contact: Contact,
446    /// Result thumbnail in JPEG format; may be null
447    thumbnail: Option<Thumbnail>,
448}
449
450impl RObject for InlineQueryResultContact {
451    #[doc(hidden)]
452    fn extra(&self) -> Option<&str> {
453        self.extra.as_deref()
454    }
455    #[doc(hidden)]
456    fn client_id(&self) -> Option<i32> {
457        self.client_id
458    }
459}
460
461impl TDInlineQueryResult for InlineQueryResultContact {}
462
463impl InlineQueryResultContact {
464    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
465        Ok(serde_json::from_str(json.as_ref())?)
466    }
467    pub fn builder() -> InlineQueryResultContactBuilder {
468        let mut inner = InlineQueryResultContact::default();
469        inner.extra = Some(Uuid::new_v4().to_string());
470
471        InlineQueryResultContactBuilder { inner }
472    }
473
474    pub fn id(&self) -> &String {
475        &self.id
476    }
477
478    pub fn contact(&self) -> &Contact {
479        &self.contact
480    }
481
482    pub fn thumbnail(&self) -> &Option<Thumbnail> {
483        &self.thumbnail
484    }
485}
486
487#[doc(hidden)]
488pub struct InlineQueryResultContactBuilder {
489    inner: InlineQueryResultContact,
490}
491
492#[deprecated]
493pub type RTDInlineQueryResultContactBuilder = InlineQueryResultContactBuilder;
494
495impl InlineQueryResultContactBuilder {
496    pub fn build(&self) -> InlineQueryResultContact {
497        self.inner.clone()
498    }
499
500    pub fn id<T: AsRef<str>>(&mut self, id: T) -> &mut Self {
501        self.inner.id = id.as_ref().to_string();
502        self
503    }
504
505    pub fn contact<T: AsRef<Contact>>(&mut self, contact: T) -> &mut Self {
506        self.inner.contact = contact.as_ref().clone();
507        self
508    }
509
510    pub fn thumbnail<T: AsRef<Thumbnail>>(&mut self, thumbnail: T) -> &mut Self {
511        self.inner.thumbnail = Some(thumbnail.as_ref().clone());
512        self
513    }
514}
515
516impl AsRef<InlineQueryResultContact> for InlineQueryResultContact {
517    fn as_ref(&self) -> &InlineQueryResultContact {
518        self
519    }
520}
521
522impl AsRef<InlineQueryResultContact> for InlineQueryResultContactBuilder {
523    fn as_ref(&self) -> &InlineQueryResultContact {
524        &self.inner
525    }
526}
527
528/// Represents a document
529#[derive(Debug, Clone, Default, Serialize, Deserialize)]
530pub struct InlineQueryResultDocument {
531    #[doc(hidden)]
532    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
533    extra: Option<String>,
534    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
535    client_id: Option<i32>,
536    /// Unique identifier of the query result
537
538    #[serde(default)]
539    id: String,
540    /// Document
541    document: Document,
542    /// Document title
543
544    #[serde(default)]
545    title: String,
546    /// Represents a document
547
548    #[serde(default)]
549    description: String,
550}
551
552impl RObject for InlineQueryResultDocument {
553    #[doc(hidden)]
554    fn extra(&self) -> Option<&str> {
555        self.extra.as_deref()
556    }
557    #[doc(hidden)]
558    fn client_id(&self) -> Option<i32> {
559        self.client_id
560    }
561}
562
563impl TDInlineQueryResult for InlineQueryResultDocument {}
564
565impl InlineQueryResultDocument {
566    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
567        Ok(serde_json::from_str(json.as_ref())?)
568    }
569    pub fn builder() -> InlineQueryResultDocumentBuilder {
570        let mut inner = InlineQueryResultDocument::default();
571        inner.extra = Some(Uuid::new_v4().to_string());
572
573        InlineQueryResultDocumentBuilder { inner }
574    }
575
576    pub fn id(&self) -> &String {
577        &self.id
578    }
579
580    pub fn document(&self) -> &Document {
581        &self.document
582    }
583
584    pub fn title(&self) -> &String {
585        &self.title
586    }
587
588    pub fn description(&self) -> &String {
589        &self.description
590    }
591}
592
593#[doc(hidden)]
594pub struct InlineQueryResultDocumentBuilder {
595    inner: InlineQueryResultDocument,
596}
597
598#[deprecated]
599pub type RTDInlineQueryResultDocumentBuilder = InlineQueryResultDocumentBuilder;
600
601impl InlineQueryResultDocumentBuilder {
602    pub fn build(&self) -> InlineQueryResultDocument {
603        self.inner.clone()
604    }
605
606    pub fn id<T: AsRef<str>>(&mut self, id: T) -> &mut Self {
607        self.inner.id = id.as_ref().to_string();
608        self
609    }
610
611    pub fn document<T: AsRef<Document>>(&mut self, document: T) -> &mut Self {
612        self.inner.document = document.as_ref().clone();
613        self
614    }
615
616    pub fn title<T: AsRef<str>>(&mut self, title: T) -> &mut Self {
617        self.inner.title = title.as_ref().to_string();
618        self
619    }
620
621    pub fn description<T: AsRef<str>>(&mut self, description: T) -> &mut Self {
622        self.inner.description = description.as_ref().to_string();
623        self
624    }
625}
626
627impl AsRef<InlineQueryResultDocument> for InlineQueryResultDocument {
628    fn as_ref(&self) -> &InlineQueryResultDocument {
629        self
630    }
631}
632
633impl AsRef<InlineQueryResultDocument> for InlineQueryResultDocumentBuilder {
634    fn as_ref(&self) -> &InlineQueryResultDocument {
635        &self.inner
636    }
637}
638
639/// Represents information about a game
640#[derive(Debug, Clone, Default, Serialize, Deserialize)]
641pub struct InlineQueryResultGame {
642    #[doc(hidden)]
643    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
644    extra: Option<String>,
645    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
646    client_id: Option<i32>,
647    /// Unique identifier of the query result
648
649    #[serde(default)]
650    id: String,
651    /// Game result
652    game: Game,
653}
654
655impl RObject for InlineQueryResultGame {
656    #[doc(hidden)]
657    fn extra(&self) -> Option<&str> {
658        self.extra.as_deref()
659    }
660    #[doc(hidden)]
661    fn client_id(&self) -> Option<i32> {
662        self.client_id
663    }
664}
665
666impl TDInlineQueryResult for InlineQueryResultGame {}
667
668impl InlineQueryResultGame {
669    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
670        Ok(serde_json::from_str(json.as_ref())?)
671    }
672    pub fn builder() -> InlineQueryResultGameBuilder {
673        let mut inner = InlineQueryResultGame::default();
674        inner.extra = Some(Uuid::new_v4().to_string());
675
676        InlineQueryResultGameBuilder { inner }
677    }
678
679    pub fn id(&self) -> &String {
680        &self.id
681    }
682
683    pub fn game(&self) -> &Game {
684        &self.game
685    }
686}
687
688#[doc(hidden)]
689pub struct InlineQueryResultGameBuilder {
690    inner: InlineQueryResultGame,
691}
692
693#[deprecated]
694pub type RTDInlineQueryResultGameBuilder = InlineQueryResultGameBuilder;
695
696impl InlineQueryResultGameBuilder {
697    pub fn build(&self) -> InlineQueryResultGame {
698        self.inner.clone()
699    }
700
701    pub fn id<T: AsRef<str>>(&mut self, id: T) -> &mut Self {
702        self.inner.id = id.as_ref().to_string();
703        self
704    }
705
706    pub fn game<T: AsRef<Game>>(&mut self, game: T) -> &mut Self {
707        self.inner.game = game.as_ref().clone();
708        self
709    }
710}
711
712impl AsRef<InlineQueryResultGame> for InlineQueryResultGame {
713    fn as_ref(&self) -> &InlineQueryResultGame {
714        self
715    }
716}
717
718impl AsRef<InlineQueryResultGame> for InlineQueryResultGameBuilder {
719    fn as_ref(&self) -> &InlineQueryResultGame {
720        &self.inner
721    }
722}
723
724/// Represents a point on the map
725#[derive(Debug, Clone, Default, Serialize, Deserialize)]
726pub struct InlineQueryResultLocation {
727    #[doc(hidden)]
728    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
729    extra: Option<String>,
730    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
731    client_id: Option<i32>,
732    /// Unique identifier of the query result
733
734    #[serde(default)]
735    id: String,
736    /// Location result
737    location: Location,
738    /// Title of the result
739
740    #[serde(default)]
741    title: String,
742    /// Result thumbnail in JPEG format; may be null
743    thumbnail: Option<Thumbnail>,
744}
745
746impl RObject for InlineQueryResultLocation {
747    #[doc(hidden)]
748    fn extra(&self) -> Option<&str> {
749        self.extra.as_deref()
750    }
751    #[doc(hidden)]
752    fn client_id(&self) -> Option<i32> {
753        self.client_id
754    }
755}
756
757impl TDInlineQueryResult for InlineQueryResultLocation {}
758
759impl InlineQueryResultLocation {
760    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
761        Ok(serde_json::from_str(json.as_ref())?)
762    }
763    pub fn builder() -> InlineQueryResultLocationBuilder {
764        let mut inner = InlineQueryResultLocation::default();
765        inner.extra = Some(Uuid::new_v4().to_string());
766
767        InlineQueryResultLocationBuilder { inner }
768    }
769
770    pub fn id(&self) -> &String {
771        &self.id
772    }
773
774    pub fn location(&self) -> &Location {
775        &self.location
776    }
777
778    pub fn title(&self) -> &String {
779        &self.title
780    }
781
782    pub fn thumbnail(&self) -> &Option<Thumbnail> {
783        &self.thumbnail
784    }
785}
786
787#[doc(hidden)]
788pub struct InlineQueryResultLocationBuilder {
789    inner: InlineQueryResultLocation,
790}
791
792#[deprecated]
793pub type RTDInlineQueryResultLocationBuilder = InlineQueryResultLocationBuilder;
794
795impl InlineQueryResultLocationBuilder {
796    pub fn build(&self) -> InlineQueryResultLocation {
797        self.inner.clone()
798    }
799
800    pub fn id<T: AsRef<str>>(&mut self, id: T) -> &mut Self {
801        self.inner.id = id.as_ref().to_string();
802        self
803    }
804
805    pub fn location<T: AsRef<Location>>(&mut self, location: T) -> &mut Self {
806        self.inner.location = location.as_ref().clone();
807        self
808    }
809
810    pub fn title<T: AsRef<str>>(&mut self, title: T) -> &mut Self {
811        self.inner.title = title.as_ref().to_string();
812        self
813    }
814
815    pub fn thumbnail<T: AsRef<Thumbnail>>(&mut self, thumbnail: T) -> &mut Self {
816        self.inner.thumbnail = Some(thumbnail.as_ref().clone());
817        self
818    }
819}
820
821impl AsRef<InlineQueryResultLocation> for InlineQueryResultLocation {
822    fn as_ref(&self) -> &InlineQueryResultLocation {
823        self
824    }
825}
826
827impl AsRef<InlineQueryResultLocation> for InlineQueryResultLocationBuilder {
828    fn as_ref(&self) -> &InlineQueryResultLocation {
829        &self.inner
830    }
831}
832
833/// Represents a photo
834#[derive(Debug, Clone, Default, Serialize, Deserialize)]
835pub struct InlineQueryResultPhoto {
836    #[doc(hidden)]
837    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
838    extra: Option<String>,
839    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
840    client_id: Option<i32>,
841    /// Unique identifier of the query result
842
843    #[serde(default)]
844    id: String,
845    /// Photo
846    photo: Photo,
847    /// Title of the result, if known
848
849    #[serde(default)]
850    title: String,
851    /// Represents a photo
852
853    #[serde(default)]
854    description: String,
855}
856
857impl RObject for InlineQueryResultPhoto {
858    #[doc(hidden)]
859    fn extra(&self) -> Option<&str> {
860        self.extra.as_deref()
861    }
862    #[doc(hidden)]
863    fn client_id(&self) -> Option<i32> {
864        self.client_id
865    }
866}
867
868impl TDInlineQueryResult for InlineQueryResultPhoto {}
869
870impl InlineQueryResultPhoto {
871    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
872        Ok(serde_json::from_str(json.as_ref())?)
873    }
874    pub fn builder() -> InlineQueryResultPhotoBuilder {
875        let mut inner = InlineQueryResultPhoto::default();
876        inner.extra = Some(Uuid::new_v4().to_string());
877
878        InlineQueryResultPhotoBuilder { inner }
879    }
880
881    pub fn id(&self) -> &String {
882        &self.id
883    }
884
885    pub fn photo(&self) -> &Photo {
886        &self.photo
887    }
888
889    pub fn title(&self) -> &String {
890        &self.title
891    }
892
893    pub fn description(&self) -> &String {
894        &self.description
895    }
896}
897
898#[doc(hidden)]
899pub struct InlineQueryResultPhotoBuilder {
900    inner: InlineQueryResultPhoto,
901}
902
903#[deprecated]
904pub type RTDInlineQueryResultPhotoBuilder = InlineQueryResultPhotoBuilder;
905
906impl InlineQueryResultPhotoBuilder {
907    pub fn build(&self) -> InlineQueryResultPhoto {
908        self.inner.clone()
909    }
910
911    pub fn id<T: AsRef<str>>(&mut self, id: T) -> &mut Self {
912        self.inner.id = id.as_ref().to_string();
913        self
914    }
915
916    pub fn photo<T: AsRef<Photo>>(&mut self, photo: T) -> &mut Self {
917        self.inner.photo = photo.as_ref().clone();
918        self
919    }
920
921    pub fn title<T: AsRef<str>>(&mut self, title: T) -> &mut Self {
922        self.inner.title = title.as_ref().to_string();
923        self
924    }
925
926    pub fn description<T: AsRef<str>>(&mut self, description: T) -> &mut Self {
927        self.inner.description = description.as_ref().to_string();
928        self
929    }
930}
931
932impl AsRef<InlineQueryResultPhoto> for InlineQueryResultPhoto {
933    fn as_ref(&self) -> &InlineQueryResultPhoto {
934        self
935    }
936}
937
938impl AsRef<InlineQueryResultPhoto> for InlineQueryResultPhotoBuilder {
939    fn as_ref(&self) -> &InlineQueryResultPhoto {
940        &self.inner
941    }
942}
943
944/// Represents a sticker
945#[derive(Debug, Clone, Default, Serialize, Deserialize)]
946pub struct InlineQueryResultSticker {
947    #[doc(hidden)]
948    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
949    extra: Option<String>,
950    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
951    client_id: Option<i32>,
952    /// Unique identifier of the query result
953
954    #[serde(default)]
955    id: String,
956    /// Sticker
957    sticker: Sticker,
958}
959
960impl RObject for InlineQueryResultSticker {
961    #[doc(hidden)]
962    fn extra(&self) -> Option<&str> {
963        self.extra.as_deref()
964    }
965    #[doc(hidden)]
966    fn client_id(&self) -> Option<i32> {
967        self.client_id
968    }
969}
970
971impl TDInlineQueryResult for InlineQueryResultSticker {}
972
973impl InlineQueryResultSticker {
974    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
975        Ok(serde_json::from_str(json.as_ref())?)
976    }
977    pub fn builder() -> InlineQueryResultStickerBuilder {
978        let mut inner = InlineQueryResultSticker::default();
979        inner.extra = Some(Uuid::new_v4().to_string());
980
981        InlineQueryResultStickerBuilder { inner }
982    }
983
984    pub fn id(&self) -> &String {
985        &self.id
986    }
987
988    pub fn sticker(&self) -> &Sticker {
989        &self.sticker
990    }
991}
992
993#[doc(hidden)]
994pub struct InlineQueryResultStickerBuilder {
995    inner: InlineQueryResultSticker,
996}
997
998#[deprecated]
999pub type RTDInlineQueryResultStickerBuilder = InlineQueryResultStickerBuilder;
1000
1001impl InlineQueryResultStickerBuilder {
1002    pub fn build(&self) -> InlineQueryResultSticker {
1003        self.inner.clone()
1004    }
1005
1006    pub fn id<T: AsRef<str>>(&mut self, id: T) -> &mut Self {
1007        self.inner.id = id.as_ref().to_string();
1008        self
1009    }
1010
1011    pub fn sticker<T: AsRef<Sticker>>(&mut self, sticker: T) -> &mut Self {
1012        self.inner.sticker = sticker.as_ref().clone();
1013        self
1014    }
1015}
1016
1017impl AsRef<InlineQueryResultSticker> for InlineQueryResultSticker {
1018    fn as_ref(&self) -> &InlineQueryResultSticker {
1019        self
1020    }
1021}
1022
1023impl AsRef<InlineQueryResultSticker> for InlineQueryResultStickerBuilder {
1024    fn as_ref(&self) -> &InlineQueryResultSticker {
1025        &self.inner
1026    }
1027}
1028
1029/// Represents information about a venue
1030#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1031pub struct InlineQueryResultVenue {
1032    #[doc(hidden)]
1033    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
1034    extra: Option<String>,
1035    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
1036    client_id: Option<i32>,
1037    /// Unique identifier of the query result
1038
1039    #[serde(default)]
1040    id: String,
1041    /// Venue result
1042    venue: Venue,
1043    /// Result thumbnail in JPEG format; may be null
1044    thumbnail: Option<Thumbnail>,
1045}
1046
1047impl RObject for InlineQueryResultVenue {
1048    #[doc(hidden)]
1049    fn extra(&self) -> Option<&str> {
1050        self.extra.as_deref()
1051    }
1052    #[doc(hidden)]
1053    fn client_id(&self) -> Option<i32> {
1054        self.client_id
1055    }
1056}
1057
1058impl TDInlineQueryResult for InlineQueryResultVenue {}
1059
1060impl InlineQueryResultVenue {
1061    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
1062        Ok(serde_json::from_str(json.as_ref())?)
1063    }
1064    pub fn builder() -> InlineQueryResultVenueBuilder {
1065        let mut inner = InlineQueryResultVenue::default();
1066        inner.extra = Some(Uuid::new_v4().to_string());
1067
1068        InlineQueryResultVenueBuilder { inner }
1069    }
1070
1071    pub fn id(&self) -> &String {
1072        &self.id
1073    }
1074
1075    pub fn venue(&self) -> &Venue {
1076        &self.venue
1077    }
1078
1079    pub fn thumbnail(&self) -> &Option<Thumbnail> {
1080        &self.thumbnail
1081    }
1082}
1083
1084#[doc(hidden)]
1085pub struct InlineQueryResultVenueBuilder {
1086    inner: InlineQueryResultVenue,
1087}
1088
1089#[deprecated]
1090pub type RTDInlineQueryResultVenueBuilder = InlineQueryResultVenueBuilder;
1091
1092impl InlineQueryResultVenueBuilder {
1093    pub fn build(&self) -> InlineQueryResultVenue {
1094        self.inner.clone()
1095    }
1096
1097    pub fn id<T: AsRef<str>>(&mut self, id: T) -> &mut Self {
1098        self.inner.id = id.as_ref().to_string();
1099        self
1100    }
1101
1102    pub fn venue<T: AsRef<Venue>>(&mut self, venue: T) -> &mut Self {
1103        self.inner.venue = venue.as_ref().clone();
1104        self
1105    }
1106
1107    pub fn thumbnail<T: AsRef<Thumbnail>>(&mut self, thumbnail: T) -> &mut Self {
1108        self.inner.thumbnail = Some(thumbnail.as_ref().clone());
1109        self
1110    }
1111}
1112
1113impl AsRef<InlineQueryResultVenue> for InlineQueryResultVenue {
1114    fn as_ref(&self) -> &InlineQueryResultVenue {
1115        self
1116    }
1117}
1118
1119impl AsRef<InlineQueryResultVenue> for InlineQueryResultVenueBuilder {
1120    fn as_ref(&self) -> &InlineQueryResultVenue {
1121        &self.inner
1122    }
1123}
1124
1125/// Represents a video
1126#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1127pub struct InlineQueryResultVideo {
1128    #[doc(hidden)]
1129    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
1130    extra: Option<String>,
1131    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
1132    client_id: Option<i32>,
1133    /// Unique identifier of the query result
1134
1135    #[serde(default)]
1136    id: String,
1137    /// Video
1138    video: Video,
1139    /// Title of the video
1140
1141    #[serde(default)]
1142    title: String,
1143    /// Represents a video
1144
1145    #[serde(default)]
1146    description: String,
1147}
1148
1149impl RObject for InlineQueryResultVideo {
1150    #[doc(hidden)]
1151    fn extra(&self) -> Option<&str> {
1152        self.extra.as_deref()
1153    }
1154    #[doc(hidden)]
1155    fn client_id(&self) -> Option<i32> {
1156        self.client_id
1157    }
1158}
1159
1160impl TDInlineQueryResult for InlineQueryResultVideo {}
1161
1162impl InlineQueryResultVideo {
1163    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
1164        Ok(serde_json::from_str(json.as_ref())?)
1165    }
1166    pub fn builder() -> InlineQueryResultVideoBuilder {
1167        let mut inner = InlineQueryResultVideo::default();
1168        inner.extra = Some(Uuid::new_v4().to_string());
1169
1170        InlineQueryResultVideoBuilder { inner }
1171    }
1172
1173    pub fn id(&self) -> &String {
1174        &self.id
1175    }
1176
1177    pub fn video(&self) -> &Video {
1178        &self.video
1179    }
1180
1181    pub fn title(&self) -> &String {
1182        &self.title
1183    }
1184
1185    pub fn description(&self) -> &String {
1186        &self.description
1187    }
1188}
1189
1190#[doc(hidden)]
1191pub struct InlineQueryResultVideoBuilder {
1192    inner: InlineQueryResultVideo,
1193}
1194
1195#[deprecated]
1196pub type RTDInlineQueryResultVideoBuilder = InlineQueryResultVideoBuilder;
1197
1198impl InlineQueryResultVideoBuilder {
1199    pub fn build(&self) -> InlineQueryResultVideo {
1200        self.inner.clone()
1201    }
1202
1203    pub fn id<T: AsRef<str>>(&mut self, id: T) -> &mut Self {
1204        self.inner.id = id.as_ref().to_string();
1205        self
1206    }
1207
1208    pub fn video<T: AsRef<Video>>(&mut self, video: T) -> &mut Self {
1209        self.inner.video = video.as_ref().clone();
1210        self
1211    }
1212
1213    pub fn title<T: AsRef<str>>(&mut self, title: T) -> &mut Self {
1214        self.inner.title = title.as_ref().to_string();
1215        self
1216    }
1217
1218    pub fn description<T: AsRef<str>>(&mut self, description: T) -> &mut Self {
1219        self.inner.description = description.as_ref().to_string();
1220        self
1221    }
1222}
1223
1224impl AsRef<InlineQueryResultVideo> for InlineQueryResultVideo {
1225    fn as_ref(&self) -> &InlineQueryResultVideo {
1226        self
1227    }
1228}
1229
1230impl AsRef<InlineQueryResultVideo> for InlineQueryResultVideoBuilder {
1231    fn as_ref(&self) -> &InlineQueryResultVideo {
1232        &self.inner
1233    }
1234}
1235
1236/// Represents a voice note
1237#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1238pub struct InlineQueryResultVoiceNote {
1239    #[doc(hidden)]
1240    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
1241    extra: Option<String>,
1242    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
1243    client_id: Option<i32>,
1244    /// Unique identifier of the query result
1245
1246    #[serde(default)]
1247    id: String,
1248    /// Voice note
1249    voice_note: VoiceNote,
1250    /// Title of the voice note
1251
1252    #[serde(default)]
1253    title: String,
1254}
1255
1256impl RObject for InlineQueryResultVoiceNote {
1257    #[doc(hidden)]
1258    fn extra(&self) -> Option<&str> {
1259        self.extra.as_deref()
1260    }
1261    #[doc(hidden)]
1262    fn client_id(&self) -> Option<i32> {
1263        self.client_id
1264    }
1265}
1266
1267impl TDInlineQueryResult for InlineQueryResultVoiceNote {}
1268
1269impl InlineQueryResultVoiceNote {
1270    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
1271        Ok(serde_json::from_str(json.as_ref())?)
1272    }
1273    pub fn builder() -> InlineQueryResultVoiceNoteBuilder {
1274        let mut inner = InlineQueryResultVoiceNote::default();
1275        inner.extra = Some(Uuid::new_v4().to_string());
1276
1277        InlineQueryResultVoiceNoteBuilder { inner }
1278    }
1279
1280    pub fn id(&self) -> &String {
1281        &self.id
1282    }
1283
1284    pub fn voice_note(&self) -> &VoiceNote {
1285        &self.voice_note
1286    }
1287
1288    pub fn title(&self) -> &String {
1289        &self.title
1290    }
1291}
1292
1293#[doc(hidden)]
1294pub struct InlineQueryResultVoiceNoteBuilder {
1295    inner: InlineQueryResultVoiceNote,
1296}
1297
1298#[deprecated]
1299pub type RTDInlineQueryResultVoiceNoteBuilder = InlineQueryResultVoiceNoteBuilder;
1300
1301impl InlineQueryResultVoiceNoteBuilder {
1302    pub fn build(&self) -> InlineQueryResultVoiceNote {
1303        self.inner.clone()
1304    }
1305
1306    pub fn id<T: AsRef<str>>(&mut self, id: T) -> &mut Self {
1307        self.inner.id = id.as_ref().to_string();
1308        self
1309    }
1310
1311    pub fn voice_note<T: AsRef<VoiceNote>>(&mut self, voice_note: T) -> &mut Self {
1312        self.inner.voice_note = voice_note.as_ref().clone();
1313        self
1314    }
1315
1316    pub fn title<T: AsRef<str>>(&mut self, title: T) -> &mut Self {
1317        self.inner.title = title.as_ref().to_string();
1318        self
1319    }
1320}
1321
1322impl AsRef<InlineQueryResultVoiceNote> for InlineQueryResultVoiceNote {
1323    fn as_ref(&self) -> &InlineQueryResultVoiceNote {
1324        self
1325    }
1326}
1327
1328impl AsRef<InlineQueryResultVoiceNote> for InlineQueryResultVoiceNoteBuilder {
1329    fn as_ref(&self) -> &InlineQueryResultVoiceNote {
1330        &self.inner
1331    }
1332}