1use serde::{Deserialize, Serialize};
2
3#[derive(Serialize, Deserialize, Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
11#[serde(deny_unknown_fields)]
12pub struct EmbedImage {
13 pub url: String,
14 pub width: u32,
15 pub height: u32,
16 pub size: SizeType,
17}
18
19#[derive(Serialize, Deserialize, Debug, Clone, Hash, Eq, PartialEq, Ord, PartialOrd)]
23#[serde(deny_unknown_fields)]
24pub struct EmbedVideo {
25 pub url: String,
26 pub width: u32,
27 pub height: u32,
28}
29
30#[derive(Serialize, Deserialize, Debug, Clone, Hash, Eq, PartialEq, Ord, PartialOrd)]
34#[serde(tag = "type")]
35#[serde(deny_unknown_fields)]
36pub enum EmbedSpecial {
37 None,
38 YouTube {
39 id: String,
40 },
41 Twitch {
42 content_type: TwitchContentType,
43 id: String,
44 },
45 Spotify {
46 content_type: String,
47 id: String,
48 },
49 Soundcloud,
50 Bandcamp {
51 content_type: BandcampContentType,
52 id: String,
53 },
54}
55
56#[derive(Serialize, Deserialize, Debug, Clone, Hash, Eq, PartialEq, Ord, PartialOrd)]
58pub enum TwitchContentType {
59 Channel,
60 Clip,
61 Video,
62}
63
64#[derive(Serialize, Deserialize, Debug, Clone, Hash, Eq, PartialEq, Ord, PartialOrd)]
66pub enum BandcampContentType {
67 Album,
68 Track,
69}
70
71#[derive(Serialize, Deserialize, Debug, Clone, Hash, Eq, PartialEq, Ord, PartialOrd)]
73pub enum SizeType {
74 Large,
75 Preview,
76}
77
78#[derive(Serialize, Deserialize, Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
81#[serde(tag = "type")]
82#[serde(deny_unknown_fields)]
83pub enum Embed {
84 None,
85 Website {
86 #[serde(default, skip_serializing_if = "Option::is_none")]
87 url: Option<String>,
88 #[serde(default, skip_serializing_if = "Option::is_none")]
89 special: Option<EmbedSpecial>,
90 #[serde(default, skip_serializing_if = "Option::is_none")]
91 title: Option<String>,
92 #[serde(default, skip_serializing_if = "Option::is_none")]
93 description: Option<String>,
94 #[serde(default, skip_serializing_if = "Option::is_none")]
95 image: Option<EmbedImage>,
96 #[serde(default, skip_serializing_if = "Option::is_none")]
97 video: Option<EmbedVideo>,
98 #[serde(default, skip_serializing_if = "Option::is_none")]
99 site_name: Option<String>,
100 #[serde(default, skip_serializing_if = "Option::is_none")]
101 icon_url: Option<String>,
102 #[serde(rename = "colour", default, skip_serializing_if = "Option::is_none")]
103 color: Option<String>,
104 },
105 Image(EmbedImage),
106}