twilight_model/channel/message/embed/
video.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
4pub struct EmbedVideo {
5    #[serde(skip_serializing_if = "Option::is_none")]
6    pub height: Option<u64>,
7    #[serde(skip_serializing_if = "Option::is_none")]
8    pub proxy_url: Option<String>,
9    #[serde(skip_serializing_if = "Option::is_none")]
10    pub url: Option<String>,
11    #[serde(skip_serializing_if = "Option::is_none")]
12    pub width: Option<u64>,
13}
14
15#[cfg(test)]
16mod tests {
17    use super::EmbedVideo;
18    use serde_test::Token;
19
20    #[test]
21    fn embed_video() {
22        let value = EmbedVideo {
23            height: Some(1440),
24            proxy_url: Some("https://proxy.cdn.example.com/1-hash.mp4".to_owned()),
25            url: Some("https://cdn.example.com/1-hash.mp4".to_owned()),
26            width: Some(2560),
27        };
28
29        serde_test::assert_tokens(
30            &value,
31            &[
32                Token::Struct {
33                    name: "EmbedVideo",
34                    len: 4,
35                },
36                Token::Str("height"),
37                Token::Some,
38                Token::U64(1440),
39                Token::Str("proxy_url"),
40                Token::Some,
41                Token::Str("https://proxy.cdn.example.com/1-hash.mp4"),
42                Token::Str("url"),
43                Token::Some,
44                Token::Str("https://cdn.example.com/1-hash.mp4"),
45                Token::Str("width"),
46                Token::Some,
47                Token::U64(2560),
48                Token::StructEnd,
49            ],
50        );
51    }
52}