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
use super::{InputFile, WithName};
use serde::{ser::Serializer, Serialize};
#[derive(Debug, PartialEq, Eq, Clone, Hash)]
#[must_use]
pub struct Thumb(pub(crate) InputFile);
impl Thumb {
pub fn with_bytes(bytes: impl Into<Vec<u8>>) -> Self {
Self(InputFile::File {
filename: "thumb.jpg".into(),
bytes: bytes.into(),
})
}
pub(super) const fn with_name<'a>(&'a self, name: &'a str) -> WithName<'a> {
self.0.with_name(name)
}
}
impl Serialize for Thumb {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
self.0.serialize(serializer, "thumb")
}
}