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
use serde::{Deserialize, Serialize};
use crate::entities::{
background_type_chat_theme::BackgroundTypeChatTheme, background_type_fill::BackgroundTypeFill,
background_type_pattern::BackgroundTypePattern,
background_type_wallpaper::BackgroundTypeWallpaper,
};
/// This object describes the type of a background. Currently, it can be one of
///
/// * [BackgroundTypeFill](https://core.telegram.org/bots/api/#backgroundtypefill)
/// * [BackgroundTypeWallpaper](https://core.telegram.org/bots/api/#backgroundtypewallpaper)
/// * [BackgroundTypePattern](https://core.telegram.org/bots/api/#backgroundtypepattern)
/// * [BackgroundTypeChatTheme](https://core.telegram.org/bots/api/#backgroundtypechattheme)
///
/// API Reference: [link](https://core.telegram.org/bots/api/#backgroundtype)
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(tag = "type")]
pub enum BackgroundType {
/// The background is automatically filled based on the selected colors.
///
/// API Reference: [link](https://core.telegram.org/bots/api/#backgroundtypefill)
#[serde(rename = "fill")]
Fill(BackgroundTypeFill),
/// The background is a wallpaper in the JPEG format.
///
/// API Reference: [link](https://core.telegram.org/bots/api/#backgroundtypewallpaper)
#[serde(rename = "wallpaper")]
Wallpaper(BackgroundTypeWallpaper),
/// The background is a PNG or TGV (gzipped subset of SVG with MIME type “application/x-tgwallpattern”) pattern to be combined with the background fill chosen by the user.
///
/// API Reference: [link](https://core.telegram.org/bots/api/#backgroundtypepattern)
#[serde(rename = "pattern")]
Pattern(BackgroundTypePattern),
/// The background is taken directly from a built-in chat theme.
///
/// API Reference: [link](https://core.telegram.org/bots/api/#backgroundtypechattheme)
#[serde(rename = "chat_theme")]
ChatTheme(BackgroundTypeChatTheme),
}
impl Default for BackgroundType {
fn default() -> Self {
Self::Fill(BackgroundTypeFill::default())
}
}
impl From<BackgroundTypeFill> for BackgroundType {
fn from(value: BackgroundTypeFill) -> Self {
Self::Fill(value)
}
}
impl From<BackgroundTypeWallpaper> for BackgroundType {
fn from(value: BackgroundTypeWallpaper) -> Self {
Self::Wallpaper(value)
}
}
impl From<BackgroundTypePattern> for BackgroundType {
fn from(value: BackgroundTypePattern) -> Self {
Self::Pattern(value)
}
}
impl From<BackgroundTypeChatTheme> for BackgroundType {
fn from(value: BackgroundTypeChatTheme) -> Self {
Self::ChatTheme(value)
}
}
// Divider: all content below this line will be preserved after code regen