rust_tdlib/types/
video_note.rs1use crate::errors::Result;
2use crate::types::*;
3use uuid::Uuid;
4
5#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7pub struct VideoNote {
8 #[doc(hidden)]
9 #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
10 extra: Option<String>,
11 #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
12 client_id: Option<i32>,
13 #[serde(default)]
16 duration: i32,
17 #[serde(default)]
20 length: i32,
21 minithumbnail: Option<Minithumbnail>,
23 thumbnail: Option<Thumbnail>,
25 video: File,
27}
28
29impl RObject for VideoNote {
30 #[doc(hidden)]
31 fn extra(&self) -> Option<&str> {
32 self.extra.as_deref()
33 }
34 #[doc(hidden)]
35 fn client_id(&self) -> Option<i32> {
36 self.client_id
37 }
38}
39
40impl VideoNote {
41 pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
42 Ok(serde_json::from_str(json.as_ref())?)
43 }
44 pub fn builder() -> VideoNoteBuilder {
45 let mut inner = VideoNote::default();
46 inner.extra = Some(Uuid::new_v4().to_string());
47
48 VideoNoteBuilder { inner }
49 }
50
51 pub fn duration(&self) -> i32 {
52 self.duration
53 }
54
55 pub fn length(&self) -> i32 {
56 self.length
57 }
58
59 pub fn minithumbnail(&self) -> &Option<Minithumbnail> {
60 &self.minithumbnail
61 }
62
63 pub fn thumbnail(&self) -> &Option<Thumbnail> {
64 &self.thumbnail
65 }
66
67 pub fn video(&self) -> &File {
68 &self.video
69 }
70}
71
72#[doc(hidden)]
73pub struct VideoNoteBuilder {
74 inner: VideoNote,
75}
76
77#[deprecated]
78pub type RTDVideoNoteBuilder = VideoNoteBuilder;
79
80impl VideoNoteBuilder {
81 pub fn build(&self) -> VideoNote {
82 self.inner.clone()
83 }
84
85 pub fn duration(&mut self, duration: i32) -> &mut Self {
86 self.inner.duration = duration;
87 self
88 }
89
90 pub fn length(&mut self, length: i32) -> &mut Self {
91 self.inner.length = length;
92 self
93 }
94
95 pub fn minithumbnail<T: AsRef<Minithumbnail>>(&mut self, minithumbnail: T) -> &mut Self {
96 self.inner.minithumbnail = Some(minithumbnail.as_ref().clone());
97 self
98 }
99
100 pub fn thumbnail<T: AsRef<Thumbnail>>(&mut self, thumbnail: T) -> &mut Self {
101 self.inner.thumbnail = Some(thumbnail.as_ref().clone());
102 self
103 }
104
105 pub fn video<T: AsRef<File>>(&mut self, video: T) -> &mut Self {
106 self.inner.video = video.as_ref().clone();
107 self
108 }
109}
110
111impl AsRef<VideoNote> for VideoNote {
112 fn as_ref(&self) -> &VideoNote {
113 self
114 }
115}
116
117impl AsRef<VideoNote> for VideoNoteBuilder {
118 fn as_ref(&self) -> &VideoNote {
119 &self.inner
120 }
121}