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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
use serde::{Deserialize, Serialize};
use super::files::document::Document;
// ---------------------------------------------------------------------------
// BackgroundFill -- tagged union on the "type" field
// ---------------------------------------------------------------------------
/// The background is filled using a single color.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct BackgroundFillSolid {
/// The color of the background fill in the RGB24 format.
pub color: i64,
}
/// The background is a gradient fill.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct BackgroundFillGradient {
/// Top color of the gradient in the RGB24 format.
pub top_color: i64,
/// Bottom color of the gradient in the RGB24 format.
pub bottom_color: i64,
/// Clockwise rotation angle of the background fill in degrees (0-359).
pub rotation_angle: i64,
}
/// The background is a freeform gradient that rotates after every message in the chat.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct BackgroundFillFreeformGradient {
/// A list of the 3 or 4 base colors that are used to generate the freeform gradient
/// in the RGB24 format.
pub colors: Vec<i64>,
}
/// The background fill of a chat. Discriminated by the `"type"` field.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(tag = "type", rename_all = "snake_case")]
#[non_exhaustive]
pub enum BackgroundFill {
/// A solid single-color fill.
Solid(BackgroundFillSolid),
/// A two-color gradient fill.
Gradient(BackgroundFillGradient),
/// A freeform gradient fill with 3 or 4 colors.
FreeformGradient(BackgroundFillFreeformGradient),
}
// ---------------------------------------------------------------------------
// BackgroundType -- tagged union on the "type" field
// ---------------------------------------------------------------------------
/// The background is automatically filled based on the selected colors.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct BackgroundTypeFill {
/// The background fill.
pub fill: BackgroundFill,
/// Dimming of the background in dark themes, as a percentage (0-100).
pub dark_theme_dimming: i64,
}
/// The background is a wallpaper in JPEG format.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct BackgroundTypeWallpaper {
/// Document with the wallpaper.
pub document: Document,
/// Dimming of the background in dark themes, as a percentage (0-100).
pub dark_theme_dimming: i64,
/// True if the wallpaper is downscaled to fit in a 450x450 square and then box-blurred.
#[serde(skip_serializing_if = "Option::is_none")]
pub is_blurred: Option<bool>,
/// True if the background moves slightly when the device is tilted.
#[serde(skip_serializing_if = "Option::is_none")]
pub is_moving: Option<bool>,
}
/// The background is a PNG or TGV pattern combined with a fill chosen by the user.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct BackgroundTypePattern {
/// Document with the pattern.
pub document: Document,
/// The background fill that is combined with the pattern.
pub fill: BackgroundFill,
/// Intensity of the pattern when shown above the filled background (0-100).
pub intensity: i64,
/// True if the background fill must be applied only to the pattern itself.
#[serde(skip_serializing_if = "Option::is_none")]
pub is_inverted: Option<bool>,
/// True if the background moves slightly when the device is tilted.
#[serde(skip_serializing_if = "Option::is_none")]
pub is_moving: Option<bool>,
}
/// The background is taken directly from a built-in chat theme.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct BackgroundTypeChatTheme {
/// Name of the chat theme, which is usually an emoji.
pub theme_name: String,
}
/// The type of background applied to a chat. Discriminated by the `"type"` field.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(tag = "type", rename_all = "snake_case")]
#[non_exhaustive]
pub enum BackgroundType {
/// The background is automatically filled based on selected colors.
Fill(BackgroundTypeFill),
/// The background is a wallpaper in JPEG format.
Wallpaper(BackgroundTypeWallpaper),
/// The background is a PNG or TGV pattern combined with a fill.
Pattern(BackgroundTypePattern),
/// The background is taken directly from a built-in chat theme.
ChatTheme(BackgroundTypeChatTheme),
}
// ---------------------------------------------------------------------------
// ChatBackground
// ---------------------------------------------------------------------------
/// Represents a chat background.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ChatBackground {
/// Type of the background.
#[serde(rename = "type")]
pub background_type: BackgroundType,
}