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
use std::fmt::Debug;
use url::Url;
#[derive(Clone, Default)]
pub struct Message {
pub title: Option<String>,
pub body: Option<String>,
pub link: Option<Url>,
pub media: Option<Vec<Media>>,
}
#[derive(Clone)]
pub enum Media {
Photo(Url),
Video(Url),
}
impl Debug for Message {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("Message")
.field("title", &self.title)
.field("body", &self.body)
.field("link", &self.link.as_ref().map(Url::as_str))
.field("media", &self.media)
.finish()
}
}
impl Debug for Media {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Photo(x) => f.debug_tuple("Photo").field(&x.as_str()).finish(),
Self::Video(x) => f.debug_tuple("Video").field(&x.as_str()).finish(),
}
}
}