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
use serde::Serialize;
#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash, Serialize)]
#[must_use]
pub struct Thumb<'a> {
#[serde(rename = "thumb_url")]
url: &'a str,
#[serde(rename = "thumb_width", skip_serializing_if = "Option::is_none")]
width: Option<usize>,
#[serde(rename = "thumb_height", skip_serializing_if = "Option::is_none")]
height: Option<usize>,
}
impl<'a> Thumb<'a> {
pub const fn new(url: &'a str) -> Self {
Self {
url,
width: None,
height: None,
}
}
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
}
}