1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
use serde::Serialize;
use crate::entities::{
input_media_animation::InputMediaAnimation,
input_media_audio::InputMediaAudio,
input_media_document::InputMediaDocument,
input_media_photo::InputMediaPhoto,
input_media_video::InputMediaVideo,
misc::input_file::{GetFiles, InputFile},
};
/// This object represents the content of a media message to be sent. It should be one of
///
/// * [InputMediaAnimation](https://core.telegram.org/bots/api/#inputmediaanimation)
/// * [InputMediaDocument](https://core.telegram.org/bots/api/#inputmediadocument)
/// * [InputMediaAudio](https://core.telegram.org/bots/api/#inputmediaaudio)
/// * [InputMediaPhoto](https://core.telegram.org/bots/api/#inputmediaphoto)
/// * [InputMediaVideo](https://core.telegram.org/bots/api/#inputmediavideo)
///
/// API Reference: [link](https://core.telegram.org/bots/api/#inputmedia)
#[derive(Debug, Clone, PartialEq, Serialize)]
#[serde(tag = "type")]
pub enum InputMedia {
/// Represents an animation file (GIF or H.264/MPEG-4 AVC video without sound) to be sent.
///
/// API Reference: [link](https://core.telegram.org/bots/api/#inputmediaanimation)
#[serde(rename = "animation")]
Animation(InputMediaAnimation),
/// Represents a general file to be sent.
///
/// API Reference: [link](https://core.telegram.org/bots/api/#inputmediadocument)
#[serde(rename = "document")]
Document(InputMediaDocument),
/// Represents an audio file to be treated as music to be sent.
///
/// API Reference: [link](https://core.telegram.org/bots/api/#inputmediaaudio)
#[serde(rename = "audio")]
Audio(InputMediaAudio),
/// Represents a photo to be sent.
///
/// API Reference: [link](https://core.telegram.org/bots/api/#inputmediaphoto)
#[serde(rename = "photo")]
Photo(InputMediaPhoto),
/// Represents a video to be sent.
///
/// API Reference: [link](https://core.telegram.org/bots/api/#inputmediavideo)
#[serde(rename = "video")]
Video(InputMediaVideo),
}
impl Default for InputMedia {
fn default() -> Self {
Self::Animation(InputMediaAnimation::default())
}
}
impl From<InputMediaAnimation> for InputMedia {
fn from(value: InputMediaAnimation) -> Self {
Self::Animation(value)
}
}
impl From<InputMediaDocument> for InputMedia {
fn from(value: InputMediaDocument) -> Self {
Self::Document(value)
}
}
impl From<InputMediaAudio> for InputMedia {
fn from(value: InputMediaAudio) -> Self {
Self::Audio(value)
}
}
impl From<InputMediaPhoto> for InputMedia {
fn from(value: InputMediaPhoto) -> Self {
Self::Photo(value)
}
}
impl From<InputMediaVideo> for InputMedia {
fn from(value: InputMediaVideo) -> Self {
Self::Video(value)
}
}
impl GetFiles for InputMedia {
fn get_files(&self) -> Vec<&InputFile> {
match self {
Self::Animation(m) => m.get_files(),
Self::Audio(m) => m.get_files(),
Self::Document(m) => m.get_files(),
Self::Photo(m) => m.get_files(),
Self::Video(m) => m.get_files(),
}
}
}
// Divider: all content below this line will be preserved after code regen