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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
use super::{InputFile, Thumb, WithName};
use serde::Serialize;
#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash, Serialize)]
pub struct VideoNote<'a> {
pub(crate) media: WithName<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
pub(crate) duration: Option<u32>,
#[serde(skip_serializing_if = "Option::is_none")]
pub(crate) length: Option<u32>,
#[serde(skip_serializing_if = "Option::is_none")]
pub(crate) thumb: Option<Thumb<'a>>,
}
impl<'a> VideoNote<'a> {
const fn new(media: InputFile<'a>) -> Self {
Self {
media: media.with_name("video_note"),
duration: None,
length: None,
thumb: None,
}
}
pub fn bytes(bytes: &'a [u8]) -> Self {
Self::new(InputFile::File {
filename: "video_note.mp4",
bytes,
})
}
pub fn id(id: &'a str) -> Self {
assert!(
!id.starts_with("attach://"),
"\n[tbot]: Video note's ID cannot start with `attach://`\n",
);
Self::new(InputFile::Id(id))
}
pub fn url(url: &'a str) -> Self {
assert!(
!url.starts_with("attach://"),
"\n[tbot]: Video note's URL cannot start with `attach://`\n",
);
Self::new(InputFile::Url(url))
}
pub fn duration(mut self, duration: u32) -> Self {
self.duration = Some(duration);
self
}
pub fn length(mut self, length: u32) -> Self {
self.length = Some(length);
self
}
pub fn thumb(mut self, thumb: Thumb<'a>) -> Self {
self.thumb = Some(thumb);
self
}
}