From 711406ba1c867080911cd4671c9da784b19975b5 Mon Sep 17 00:00:00 2001 From: Temirkhan Myrzamadi Date: Tue, 28 Jul 2020 20:41:55 +0600 Subject: [PATCH] Add setters to VideoNote --- src/types/video_note.rs | 53 +++++++++++++++++++++++++++++++++++++++++ src/types/voice.rs | 2 ++ 2 files changed, 55 insertions(+) diff --git a/src/types/video_note.rs b/src/types/video_note.rs index 399ebc72..467ace0e 100644 --- a/src/types/video_note.rs +++ b/src/types/video_note.rs @@ -34,3 +34,56 @@ pub struct VideoNote { /// File size. pub file_size: Option, } + +impl VideoNote { + pub fn new(file_id: S1, file_unique_id: S2, length: u32, duration: u32) -> Self + where + S1: Into, + S2: Into, + { + Self { + file_id: file_id.into(), + file_unique_id: file_unique_id.into(), + length, + duration, + thumb: None, + file_size: None, + } + } + + pub fn file_id(mut self, val: S) -> Self + where + S: Into, + { + self.file_id = val.into(); + self + } + + pub fn file_unique_id(mut self, val: S) -> Self + where + S: Into, + { + self.file_unique_id = val.into(); + self + } + + pub fn length(mut self, val: u32) -> Self { + self.length = val; + self + } + + pub fn duration(mut self, val: u32) -> Self { + self.duration = val; + self + } + + pub fn thumb(mut self, val: PhotoSize) -> Self { + self.thumb = Some(val); + self + } + + pub fn file_size(mut self, val: u32) -> Self { + self.file_size = Some(val); + self + } +} diff --git a/src/types/voice.rs b/src/types/voice.rs index 914f5648..2d823d30 100644 --- a/src/types/voice.rs +++ b/src/types/voice.rs @@ -25,3 +25,5 @@ pub struct Voice { /// File size. pub file_size: Option, } + +impl Voice {}