From c5b0bb93cac819ff2a85c13cf485a5fde96a99f8 Mon Sep 17 00:00:00 2001 From: Temirkhan Myrzamadi Date: Mon, 27 Jul 2020 14:10:56 +0600 Subject: [PATCH] Add setters to Audio --- src/types/audio.rs | 71 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/src/types/audio.rs b/src/types/audio.rs index 6388056a..d5599c20 100644 --- a/src/types/audio.rs +++ b/src/types/audio.rs @@ -37,6 +37,77 @@ pub struct Audio { pub thumb: Option, } +impl Audio { + pub fn new(file_id: S1, file_unique_id: S2, duration: u32) -> Self + where + S1: Into, + S2: Into, + { + Self { + file_id: file_id.into(), + file_unique_id: file_unique_id.into(), + duration, + performer: None, + title: None, + mime_type: None, + file_size: None, + thumb: 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 duration(mut self, val: u32) -> Self { + self.duration = val; + self + } + + pub fn performer(mut self, val: S) -> Self + where + S: Into, + { + self.performer = Some(val.into()); + self + } + + pub fn title(mut self, val: S) -> Self + where + S: Into, + { + self.title = Some(val.into()); + self + } + + pub fn mime_type(mut self, val: MimeWrapper) -> Self { + self.mime_type = Some(val); + self + } + + pub fn file_size(mut self, val: u32) -> Self { + self.file_size = Some(val); + self + } + + pub fn thumb(mut self, val: PhotoSize) -> Self { + self.thumb = Some(val); + self + } +} + #[cfg(test)] mod tests { use super::*;