From f4a87b0d70a39ac496dd02e8e24d7e948d63c751 Mon Sep 17 00:00:00 2001 From: Temirkhan Myrzamadi Date: Tue, 28 Jul 2020 20:00:51 +0600 Subject: [PATCH] Add setters to Sticker --- src/types/sticker.rs | 90 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/src/types/sticker.rs b/src/types/sticker.rs index 0548da42..d133f1cc 100644 --- a/src/types/sticker.rs +++ b/src/types/sticker.rs @@ -43,3 +43,93 @@ pub struct Sticker { /// File size. pub file_size: Option, } + +impl Sticker { + pub fn new( + file_id: S1, + file_unique_id: S2, + width: u16, + height: u16, + is_animated: bool, + ) -> Self + where + S1: Into, + S2: Into, + { + Self { + file_id: file_id.into(), + file_unique_id: file_unique_id.into(), + width, + height, + is_animated, + thumb: None, + emoji: None, + set_name: None, + mask_position: 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 height(mut self, val: u16) -> Self { + self.height = val; + self + } + + pub fn width(mut self, val: u16) -> Self { + self.width = val; + self + } + + #[allow(clippy::wrong_self_convention)] + pub fn is_animated(mut self, val: bool) -> Self { + self.is_animated = val; + self + } + + pub fn thumb(mut self, val: PhotoSize) -> Self { + self.thumb = Some(val); + self + } + + pub fn emoji(mut self, val: S) -> Self + where + S: Into, + { + self.emoji = Some(val.into()); + self + } + + pub fn set_name(mut self, val: S) -> Self + where + S: Into, + { + self.set_name = Some(val.into()); + self + } + + pub fn mask_position(mut self, val: MaskPosition) -> Self { + self.mask_position = Some(val); + self + } + + pub fn file_size(mut self, val: u32) -> Self { + self.file_size = Some(val); + self + } +}