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
use serde::Serialize;
#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash, Serialize)]
#[must_use]
pub struct Photo<'a> {
#[serde(rename = "photo_url")]
url: &'a str,
#[serde(skip_serializing_if = "Option::is_none", rename = "photo_size")]
size: Option<usize>,
#[serde(skip_serializing_if = "Option::is_none", rename = "photo_width")]
width: Option<usize>,
#[serde(skip_serializing_if = "Option::is_none", rename = "photo_height")]
height: Option<usize>,
}
impl<'a> Photo<'a> {
pub const fn new(url: &'a str) -> Self {
Self {
url,
size: None,
width: None,
height: None,
}
}
pub fn size(mut self, size: usize) -> Self {
self.size = Some(size);
self
}
pub fn width(mut self, width: usize) -> Self {
self.width = Some(width);
self
}
pub fn height(mut self, height: usize) -> Self {
self.height = Some(height);
self
}
}