rive_models/
embed.rs

1use crate::attachment::Attachment;
2use serde::{Deserialize, Serialize};
3
4/// Embed
5#[derive(Deserialize, Debug, Clone)]
6#[serde(tag = "type")]
7pub enum Embed {
8    Website(WebsiteMetadata),
9    Image(Image),
10    Video(Video),
11    Text(Text),
12    None,
13}
14
15/// Representation of a text embed before it is sent.
16#[derive(Serialize, Deserialize, Clone, Debug, Default)]
17pub struct SendableEmbed {
18    #[serde(skip_serializing_if = "Option::is_none")]
19    pub icon_url: Option<String>,
20    #[serde(skip_serializing_if = "Option::is_none")]
21    pub url: Option<String>,
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub title: Option<String>,
24    #[serde(skip_serializing_if = "Option::is_none")]
25    pub description: Option<String>,
26    #[serde(skip_serializing_if = "Option::is_none")]
27    pub media: Option<String>,
28    #[serde(skip_serializing_if = "Option::is_none")]
29    pub colour: Option<String>,
30}
31
32/// Image
33#[derive(Deserialize, Debug, Clone)]
34pub struct Image {
35    /// URL to the original image
36    pub url: String,
37
38    /// Width of the image
39    pub width: isize,
40
41    /// Height of the image
42    pub height: isize,
43
44    /// Positioning and size
45    pub size: ImageSize,
46}
47
48/// Image positioning and size
49#[derive(Deserialize, Debug, Clone)]
50pub enum ImageSize {
51    /// Show large preview at the bottom of the embed
52    Large,
53
54    /// Show small preview to the side of the embed
55    Preview,
56}
57
58/// Video
59#[derive(Deserialize, Debug, Clone)]
60pub struct Video {
61    /// URL to the original video
62    pub url: String,
63
64    /// Width of the video
65    pub width: isize,
66
67    /// Height of the video
68    pub height: isize,
69}
70
71/// Text Embed
72#[derive(Deserialize, Debug, Clone)]
73pub struct Text {
74    /// URL to icon
75    pub icon_url: Option<String>,
76
77    /// URL for title
78    pub url: Option<String>,
79
80    /// Title of text embed
81    pub title: Option<String>,
82
83    /// Description of text embed
84    pub description: Option<String>,
85
86    /// ID of uploaded attachment
87    pub media: Option<Attachment>,
88
89    /// CSS colour
90    pub colour: Option<String>,
91}
92
93/// Information about special remote content
94#[derive(Deserialize, Debug, Clone)]
95#[serde(tag = "type")]
96pub enum Special {
97    /// No remote content
98    None,
99
100    /// Content hint that this contains a GIF
101    ///
102    /// Use metadata to find video or image to play
103    GIF,
104
105    /// YouTube video
106    YouTube {
107        id: String,
108        timestamp: Option<String>,
109    },
110
111    /// Lightspeed.tv stream
112    Lightspeed {
113        content_type: LightspeedType,
114        id: String,
115    },
116
117    /// Twitch stream or clip
118    Twitch {
119        content_type: TwitchType,
120        id: String,
121    },
122    /// Spotify track
123    Spotify { content_type: String, id: String },
124
125    /// Soundcloud track
126    Soundcloud,
127
128    /// Bandcamp track
129    Bandcamp {
130        content_type: BandcampType,
131        id: String,
132    },
133}
134
135/// Type of remote Twitch content
136#[derive(Deserialize, Debug, Clone)]
137pub enum TwitchType {
138    Channel,
139    Video,
140    Clip,
141}
142
143/// Type of remote Lightspeed.tv content
144#[derive(Deserialize, Debug, Clone)]
145pub enum LightspeedType {
146    Channel,
147}
148
149/// Type of remote Bandcamp content
150#[derive(Deserialize, Debug, Clone)]
151pub enum BandcampType {
152    Album,
153    Track,
154}
155
156/// Website metadata
157#[derive(Deserialize, Debug, Clone)]
158pub struct WebsiteMetadata {
159    /// Direct URL to web page
160    pub url: Option<String>,
161
162    /// Original direct URL
163    pub original_url: Option<String>,
164
165    /// Remote content
166    pub special: Option<Special>,
167
168    /// Title of website
169    pub title: Option<String>,
170
171    /// Description of website
172    pub description: Option<String>,
173
174    /// Embedded image
175    pub image: Option<Image>,
176
177    /// Embedded video
178    pub video: Option<Video>,
179
180    /// Site name
181    pub site_name: Option<String>,
182
183    /// URL to site icon
184    pub icon_url: Option<String>,
185
186    /// CSS colour
187    pub colour: Option<String>,
188}