tgbot/types/input/message_content/
mod.rs

1use serde::{Deserialize, Serialize};
2
3pub use self::{contact::*, invoice::*, location::*, text::*, venue::*};
4use crate::types::{Contact, Location, Text, Venue};
5
6mod contact;
7mod invoice;
8mod location;
9mod text;
10mod venue;
11
12#[cfg(test)]
13mod tests;
14
15/// Represents a content of a message to be sent as a result of an inline query.
16#[derive(Clone, Debug, derive_more::From, Deserialize, PartialEq, PartialOrd, Serialize)]
17#[serde(untagged)]
18pub enum InputMessageContent {
19    /// Represents a contact.
20    Contact(InputMessageContentContact),
21    /// Represents an invoice.
22    Invoice(InputMessageContentInvoice),
23    /// Represents a venue.
24    Venue(InputMessageContentVenue),
25    /// Represents a location.
26    Location(InputMessageContentLocation),
27    /// Represents a text.
28    Text(InputMessageContentText),
29}
30
31impl From<Contact> for InputMessageContent {
32    fn from(value: Contact) -> Self {
33        Self::Contact(value.into())
34    }
35}
36
37impl From<Location> for InputMessageContent {
38    fn from(value: Location) -> Self {
39        Self::Location(value.into())
40    }
41}
42
43impl<T> From<T> for InputMessageContent
44where
45    T: Into<String>,
46{
47    fn from(value: T) -> Self {
48        Self::Text(value.into().into())
49    }
50}
51
52impl From<Text> for InputMessageContent {
53    fn from(value: Text) -> Self {
54        Self::Text(value.into())
55    }
56}
57
58impl From<Venue> for InputMessageContent {
59    fn from(value: Venue) -> Self {
60        Self::Venue(value.into())
61    }
62}