From 393f6ee7a40df6949fefa18009ff542fb7095389 Mon Sep 17 00:00:00 2001 From: Waffle Date: Tue, 26 Jan 2021 15:35:08 +0300 Subject: [PATCH] Cleanup setters in types::* - Remove useless setters for types which are only returned from telegam - Add `const` on setters (where possible) - Make `Poll::{open_period,close_date}` public --- src/types/animation.rs | 80 --- src/types/audio.rs | 71 --- src/types/callback_query.rs | 68 --- src/types/chat.rs | 114 ----- src/types/chat_permissions.rs | 53 +- src/types/chat_photo.rs | 54 -- src/types/chosen_inline_result.rs | 50 -- src/types/contact.rs | 53 -- src/types/dice.rs | 16 - src/types/document.rs | 56 -- src/types/encrypted_credentials.rs | 39 -- src/types/encrypted_passport_element.rs | 417 --------------- src/types/file.rs | 45 -- src/types/force_reply.rs | 9 +- src/types/game.rs | 63 --- src/types/game_high_score.rs | 25 - src/types/input_media.rs | 41 +- src/types/input_message_content.rs | 8 +- src/types/invoice.rs | 61 --- src/types/keyboard_button.rs | 4 +- src/types/location.rs | 19 - src/types/me.rs | 39 -- src/types/message.rs | 652 ------------------------ src/types/message_entity.rs | 6 +- src/types/order_info.rs | 50 -- src/types/passport_data.rs | 25 - src/types/passport_file.rs | 41 -- src/types/photo_size.rs | 47 -- src/types/poll.rs | 146 +----- src/types/poll_answer.rs | 35 -- src/types/pre_checkout_query.rs | 68 --- src/types/reply_keyboard_remove.rs | 14 +- src/types/shipping_address.rs | 73 --- src/types/shipping_query.rs | 46 -- src/types/sticker.rs | 90 ---- src/types/sticker_set.rs | 59 --- src/types/successful_payment.rs | 72 --- src/types/update.rs | 16 - src/types/user.rs | 59 --- src/types/user_profile_photos.rs | 27 - src/types/venue.rs | 48 -- src/types/video.rs | 71 --- src/types/video_note.rs | 53 -- src/types/voice.rs | 47 -- src/types/webhook_info.rs | 63 --- 45 files changed, 98 insertions(+), 3095 deletions(-) diff --git a/src/types/animation.rs b/src/types/animation.rs index ae0c9de5..e057aad5 100644 --- a/src/types/animation.rs +++ b/src/types/animation.rs @@ -41,86 +41,6 @@ pub struct Animation { pub file_size: Option, } -impl Animation { - pub fn new( - file_id: S1, - file_unique_id: S2, - width: u32, - height: u32, - duration: u32, - ) -> Self - where - S1: Into, - S2: Into, - { - Self { - file_id: file_id.into(), - file_unique_id: file_unique_id.into(), - width, - height, - duration, - thumb: None, - file_name: None, - mime_type: 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 width(mut self, val: u32) -> Self { - self.width = val; - self - } - - pub fn height(mut self, val: u32) -> Self { - self.height = 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_name(mut self, val: S) -> Self - where - S: Into, - { - self.file_name = Some(val.into()); - self - } - - pub fn mime_type(mut self, val: Mime) -> Self { - self.mime_type = Some(val); - self - } - - pub fn file_size(mut self, val: u32) -> Self { - self.file_size = Some(val); - self - } -} - #[cfg(test)] mod tests { use super::*; diff --git a/src/types/audio.rs b/src/types/audio.rs index 23225eba..1bf3174f 100644 --- a/src/types/audio.rs +++ b/src/types/audio.rs @@ -38,77 +38,6 @@ 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: Mime) -> 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::*; diff --git a/src/types/callback_query.rs b/src/types/callback_query.rs index 611c23c1..47cedb96 100644 --- a/src/types/callback_query.rs +++ b/src/types/callback_query.rs @@ -49,74 +49,6 @@ pub struct CallbackQuery { pub game_short_name: Option, } -impl CallbackQuery { - pub fn new(id: S1, from: User, chat_instance: S2) -> Self - where - S1: Into, - S2: Into, - { - Self { - id: id.into(), - from, - message: None, - inline_message_id: None, - chat_instance: chat_instance.into(), - data: None, - game_short_name: None, - } - } - - pub fn id(mut self, id: S) -> Self - where - S: Into, - { - self.id = id.into(); - self - } - - pub fn from(mut self, val: User) -> Self { - self.from = val; - self - } - - pub fn message(mut self, val: Message) -> Self { - self.message = Some(val); - self - } - - pub fn inline_message_id(mut self, val: S) -> Self - where - S: Into, - { - self.inline_message_id = Some(val.into()); - self - } - - pub fn chat_instance(mut self, val: S) -> Self - where - S: Into, - { - self.chat_instance = val.into(); - self - } - - pub fn data(mut self, val: S) -> Self - where - S: Into, - { - self.data = Some(val.into()); - self - } - - pub fn game_short_name(mut self, val: S) -> Self - where - S: Into, - { - self.game_short_name = Some(val.into()); - self - } -} - #[cfg(test)] mod tests { use super::*; diff --git a/src/types/chat.rs b/src/types/chat.rs index 3ac14786..d0ce754e 100644 --- a/src/types/chat.rs +++ b/src/types/chat.rs @@ -24,31 +24,6 @@ pub struct Chat { pub photo: Option, } -impl Chat { - pub fn new(id: i64, kind: ChatKind) -> Self { - Self { - id, - kind, - photo: None, - } - } - - pub fn id(mut self, val: i64) -> Self { - self.id = val; - self - } - - pub fn kind(mut self, val: ChatKind) -> Self { - self.kind = val; - self - } - - pub fn photo(mut self, val: ChatPhoto) -> Self { - self.photo = Some(val); - self - } -} - #[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[serde(untagged)] @@ -91,47 +66,6 @@ pub struct ChatPublic { pub pinned_message: Option>, } -impl ChatPublic { - pub fn new(kind: PublicChatKind) -> Self { - Self { - title: None, - kind, - description: None, - invite_link: None, - pinned_message: None, - } - } - - pub fn title(mut self, val: S) -> Self - where - S: Into, - { - self.title = Some(val.into()); - self - } - - pub fn description(mut self, val: S) -> Self - where - S: Into, - { - self.description = Some(val.into()); - self - } - - pub fn invite_link(mut self, val: S) -> Self - where - S: Into, - { - self.invite_link = Some(val.into()); - self - } - - pub fn pinned_message(mut self, val: Message) -> Self { - self.pinned_message = Some(Box::new(val)); - self - } -} - #[serde_with_macros::skip_serializing_none] #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct ChatPrivate { @@ -152,36 +86,6 @@ pub struct ChatPrivate { pub last_name: Option, } -impl ChatPrivate { - pub fn new() -> Self { - Self::default() - } - - pub fn username(mut self, val: S) -> Self - where - S: Into, - { - self.username = Some(val.into()); - self - } - - pub fn first_name(mut self, val: S) -> Self - where - S: Into, - { - self.first_name = Some(val.into()); - self - } - - pub fn last_name(mut self, val: S) -> Self - where - S: Into, - { - self.last_name = Some(val.into()); - self - } -} - #[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "snake_case")] @@ -199,12 +103,6 @@ pub struct PublicChatChannel { pub username: Option, } -impl PublicChatChannel { - pub fn new() -> Self { - Self::default() - } -} - #[serde_with_macros::skip_serializing_none] #[derive(Clone, Default, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct PublicChatGroup { @@ -215,12 +113,6 @@ pub struct PublicChatGroup { pub permissions: Option, } -impl PublicChatGroup { - pub fn new() -> Self { - Self::default() - } -} - #[serde_with_macros::skip_serializing_none] #[derive(Clone, Default, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct PublicChatSupergroup { @@ -253,12 +145,6 @@ pub struct PublicChatSupergroup { pub slow_mode_delay: Option, } -impl PublicChatSupergroup { - pub fn new() -> Self { - Self::default() - } -} - struct PrivateChatKindVisitor; impl<'de> serde::de::Visitor<'de> for PrivateChatKindVisitor { diff --git a/src/types/chat_permissions.rs b/src/types/chat_permissions.rs index 139f261e..d95b6643 100644 --- a/src/types/chat_permissions.rs +++ b/src/types/chat_permissions.rs @@ -41,7 +41,56 @@ pub struct ChatPermissions { } impl ChatPermissions { - pub fn new() -> Self { - Self::default() + pub const fn new() -> Self { + Self { + can_send_messages: None, + can_send_media_messages: None, + can_send_polls: None, + can_send_other_messages: None, + can_add_web_page_previews: None, + can_change_info: None, + can_invite_users: None, + can_pin_messages: None, + } + } + + pub const fn can_send_messages(mut self, val: bool) -> Self { + self.can_send_messages = Some(val); + self + } + + pub const fn can_send_media_messages(mut self, val: bool) -> Self { + self.can_send_media_messages = Some(val); + self + } + + pub const fn can_send_polls(mut self, val: bool) -> Self { + self.can_send_polls = Some(val); + self + } + + pub const fn can_send_other_messages(mut self, val: bool) -> Self { + self.can_send_other_messages = Some(val); + self + } + + pub const fn can_add_web_page_previews(mut self, val: bool) -> Self { + self.can_add_web_page_previews = Some(val); + self + } + + pub const fn can_change_info(mut self, val: bool) -> Self { + self.can_change_info = Some(val); + self + } + + pub const fn can_invite_users(mut self, val: bool) -> Self { + self.can_invite_users = Some(val); + self + } + + pub const fn can_pin_messages(mut self, val: bool) -> Self { + self.can_pin_messages = Some(val); + self } } diff --git a/src/types/chat_photo.rs b/src/types/chat_photo.rs index dc19be54..3ebd2bb6 100644 --- a/src/types/chat_photo.rs +++ b/src/types/chat_photo.rs @@ -25,57 +25,3 @@ pub struct ChatPhoto { /// download or reuse the file. pub big_file_unique_id: String, } - -impl ChatPhoto { - pub fn new( - small_file_id: S1, - small_file_unique_id: S2, - big_file_id: S3, - big_file_unique_id: S4, - ) -> Self - where - S1: Into, - S2: Into, - S3: Into, - S4: Into, - { - Self { - small_file_id: small_file_id.into(), - small_file_unique_id: small_file_unique_id.into(), - big_file_id: big_file_id.into(), - big_file_unique_id: big_file_unique_id.into(), - } - } - - pub fn small_file_id(mut self, val: S) -> Self - where - S: Into, - { - self.small_file_id = val.into(); - self - } - - pub fn small_file_unique_id(mut self, val: S) -> Self - where - S: Into, - { - self.small_file_unique_id = val.into(); - self - } - - pub fn big_file_id(mut self, val: S) -> Self - where - S: Into, - { - self.big_file_id = val.into(); - self - } - - pub fn big_file_unique_id(mut self, val: S) -> Self - where - S: Into, - { - self.big_file_unique_id = val.into(); - self - } -} diff --git a/src/types/chosen_inline_result.rs b/src/types/chosen_inline_result.rs index b3aed6ee..458ec465 100644 --- a/src/types/chosen_inline_result.rs +++ b/src/types/chosen_inline_result.rs @@ -32,53 +32,3 @@ pub struct ChosenInlineResult { /// The query that was used to obtain the result. pub query: String, } - -impl ChosenInlineResult { - pub fn new(result_id: S1, from: User, query: S2) -> Self - where - S1: Into, - S2: Into, - { - Self { - result_id: result_id.into(), - from, - location: None, - inline_message_id: None, - query: query.into(), - } - } - - pub fn result_id(mut self, val: S) -> Self - where - S: Into, - { - self.result_id = val.into(); - self - } - - pub fn from(mut self, val: User) -> Self { - self.from = val; - self - } - - pub fn location(mut self, val: Location) -> Self { - self.location = val.into(); - self - } - - pub fn inline_message_id(mut self, val: S) -> Self - where - S: Into, - { - self.inline_message_id = Some(val.into()); - self - } - - pub fn query(mut self, val: S) -> Self - where - S: Into, - { - self.query = val.into(); - self - } -} diff --git a/src/types/contact.rs b/src/types/contact.rs index 74661c50..147d31dd 100644 --- a/src/types/contact.rs +++ b/src/types/contact.rs @@ -23,56 +23,3 @@ pub struct Contact { /// [vCard]: https://en.wikipedia.org/wiki/VCard pub vcard: Option, } - -impl Contact { - pub fn new(phone_number: S1, first_name: S2) -> Self - where - S1: Into, - S2: Into, - { - Self { - phone_number: phone_number.into(), - first_name: first_name.into(), - last_name: None, - user_id: None, - vcard: None, - } - } - - pub fn phone_number(mut self, val: S) -> Self - where - S: Into, - { - self.phone_number = val.into(); - self - } - - pub fn first_name(mut self, val: S) -> Self - where - S: Into, - { - self.first_name = val.into(); - self - } - - pub fn last_name(mut self, val: S) -> Self - where - S: Into, - { - self.last_name = Some(val.into()); - self - } - - pub fn user_id(mut self, val: i32) -> Self { - self.user_id = Some(val); - self - } - - pub fn vcard(mut self, val: S) -> Self - where - S: Into, - { - self.vcard = Some(val.into()); - self - } -} diff --git a/src/types/dice.rs b/src/types/dice.rs index c06c5050..404abd8e 100644 --- a/src/types/dice.rs +++ b/src/types/dice.rs @@ -19,19 +19,3 @@ pub struct Dice { /// [`DiceEmoji::Basketball`]:crate::types::DiceEmoji::Basketball value: i32, } - -impl Dice { - pub fn new(emoji: DiceEmoji, value: i32) -> Self { - Self { emoji, value } - } - - pub fn emoji(mut self, val: DiceEmoji) -> Self { - self.emoji = val; - self - } - - pub fn value(mut self, val: i32) -> Self { - self.value = val; - self - } -} diff --git a/src/types/document.rs b/src/types/document.rs index 75e28918..3ea3c861 100644 --- a/src/types/document.rs +++ b/src/types/document.rs @@ -35,59 +35,3 @@ pub struct Document { /// A size of a file. pub file_size: Option, } - -impl Document { - pub fn new(file_id: S1, file_unique_id: S2) -> Self - where - S1: Into, - S2: Into, - { - Self { - file_id: file_id.into(), - file_unique_id: file_unique_id.into(), - thumb: None, - file_name: None, - mime_type: 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 thumb(mut self, val: PhotoSize) -> Self { - self.thumb = Some(val); - self - } - - pub fn file_name(mut self, val: S) -> Self - where - S: Into, - { - self.file_name = Some(val.into()); - self - } - - pub fn mime_type(mut self, val: Mime) -> Self { - self.mime_type = Some(val); - self - } - - pub fn file_size(mut self, val: u32) -> Self { - self.file_size = Some(val); - self - } -} diff --git a/src/types/encrypted_credentials.rs b/src/types/encrypted_credentials.rs index 5e3562a5..583821e7 100644 --- a/src/types/encrypted_credentials.rs +++ b/src/types/encrypted_credentials.rs @@ -30,45 +30,6 @@ pub struct EncryptedCredentials { pub secret: String, } -impl EncryptedCredentials { - pub fn new(data: S1, hash: S2, secret: S3) -> Self - where - S1: Into, - S2: Into, - S3: Into, - { - Self { - data: data.into(), - hash: hash.into(), - secret: secret.into(), - } - } - - pub fn data(mut self, val: S) -> Self - where - S: Into, - { - self.data = val.into(); - self - } - - pub fn hash(mut self, val: S) -> Self - where - S: Into, - { - self.hash = val.into(); - self - } - - pub fn secret(mut self, val: S) -> Self - where - S: Into, - { - self.secret = val.into(); - self - } -} - #[cfg(test)] mod tests { use super::*; diff --git a/src/types/encrypted_passport_element.rs b/src/types/encrypted_passport_element.rs index 584e9d9a..3d392f57 100644 --- a/src/types/encrypted_passport_element.rs +++ b/src/types/encrypted_passport_element.rs @@ -19,31 +19,6 @@ pub struct EncryptedPassportElement { pub kind: EncryptedPassportElementKind, } -impl EncryptedPassportElement { - pub fn new(hash: S, kind: EncryptedPassportElementKind) -> Self - where - S: Into, - { - Self { - hash: hash.into(), - kind, - } - } - - pub fn hash(mut self, val: S) -> Self - where - S: Into, - { - self.hash = val.into(); - self - } - - pub fn kind(mut self, val: EncryptedPassportElementKind) -> Self { - self.kind = val; - self - } -} - #[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "snake_case")] #[allow(clippy::large_enum_variant)] @@ -77,23 +52,6 @@ pub struct EncryptedPassportElementPersonalDetails { pub data: String, } -impl EncryptedPassportElementPersonalDetails { - pub fn new(data: S) -> Self - where - S: Into, - { - Self { data: data.into() } - } - - pub fn data(mut self, val: S) -> Self - where - S: Into, - { - self.data = val.into(); - self - } -} - #[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct EncryptedPassportElementPassport { @@ -138,46 +96,6 @@ pub struct EncryptedPassportElementPassport { pub translation: Option>, } -impl EncryptedPassportElementPassport { - pub fn new(data: S, front_side: PassportFile, selfie: PassportFile) -> Self - where - S: Into, - { - Self { - data: data.into(), - front_side, - selfie, - translation: None, - } - } - - pub fn data(mut self, val: S) -> Self - where - S: Into, - { - self.data = val.into(); - self - } - - pub fn front_side(mut self, val: PassportFile) -> Self { - self.front_side = val; - self - } - - pub fn selfie(mut self, val: PassportFile) -> Self { - self.selfie = val; - self - } - - pub fn translation

(mut self, val: P) -> Self - where - P: Into>, - { - self.translation = Some(val.into()); - self - } -} - #[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct EncryptedPassportElementDriverLicense { @@ -231,56 +149,6 @@ pub struct EncryptedPassportElementDriverLicense { pub translation: Option>, } -impl EncryptedPassportElementDriverLicense { - pub fn new( - data: S, - front_side: PassportFile, - reverse_side: PassportFile, - selfie: PassportFile, - ) -> Self - where - S: Into, - { - Self { - data: data.into(), - front_side, - reverse_side, - selfie, - translation: None, - } - } - - pub fn data(mut self, val: S) -> Self - where - S: Into, - { - self.data = val.into(); - self - } - - pub fn front_side(mut self, val: PassportFile) -> Self { - self.front_side = val; - self - } - - pub fn reverse_side(mut self, val: PassportFile) -> Self { - self.reverse_side = val; - self - } - - pub fn selfie(mut self, val: PassportFile) -> Self { - self.selfie = val; - self - } - pub fn translation

(mut self, val: P) -> Self - where - P: Into>, - { - self.translation = Some(val.into()); - self - } -} - #[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct EncryptedPassportElementIdentityCard { @@ -334,56 +202,6 @@ pub struct EncryptedPassportElementIdentityCard { pub translation: Option>, } -impl EncryptedPassportElementIdentityCard { - pub fn new( - data: S, - front_side: PassportFile, - reverse_side: PassportFile, - selfie: PassportFile, - ) -> Self - where - S: Into, - { - Self { - data: data.into(), - front_side, - reverse_side, - selfie, - translation: None, - } - } - - pub fn data(mut self, val: S) -> Self - where - S: Into, - { - self.data = val.into(); - self - } - - pub fn front_side(mut self, val: PassportFile) -> Self { - self.front_side = val; - self - } - - pub fn reverse_side(mut self, val: PassportFile) -> Self { - self.reverse_side = val; - self - } - - pub fn selfie(mut self, val: PassportFile) -> Self { - self.selfie = val; - self - } - pub fn translation

(mut self, val: P) -> Self - where - P: Into>, - { - self.translation = Some(val.into()); - self - } -} - #[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct EncryptedPassportElementInternalPassport { @@ -428,46 +246,6 @@ pub struct EncryptedPassportElementInternalPassport { pub translation: Option>, } -impl EncryptedPassportElementInternalPassport { - pub fn new(data: S, front_side: PassportFile, selfie: PassportFile) -> Self - where - S: Into, - { - Self { - data: data.into(), - front_side, - selfie, - translation: None, - } - } - - pub fn data(mut self, val: S) -> Self - where - S: Into, - { - self.data = val.into(); - self - } - - pub fn front_side(mut self, val: PassportFile) -> Self { - self.front_side = val; - self - } - - pub fn selfie(mut self, val: PassportFile) -> Self { - self.selfie = val; - self - } - - pub fn translation

(mut self, val: P) -> Self - where - P: Into>, - { - self.translation = Some(val.into()); - self - } -} - #[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct EncryptedPassportElementAddress { @@ -482,23 +260,6 @@ pub struct EncryptedPassportElementAddress { pub data: String, } -impl EncryptedPassportElementAddress { - pub fn new(data: S) -> Self - where - S: Into, - { - Self { data: data.into() } - } - - pub fn data(mut self, val: S) -> Self - where - S: Into, - { - self.data = val.into(); - self - } -} - #[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct EncryptedPassportElementUtilityBill { @@ -525,34 +286,6 @@ pub struct EncryptedPassportElementUtilityBill { pub translation: Option>, } -impl EncryptedPassportElementUtilityBill { - pub fn new(files: F) -> Self - where - F: Into>, - { - Self { - files: files.into(), - translation: None, - } - } - - pub fn files

(mut self, val: P) -> Self - where - P: Into>, - { - self.files = val.into(); - self - } - - pub fn translation

(mut self, val: P) -> Self - where - P: Into>, - { - self.translation = Some(val.into()); - self - } -} - #[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct EncryptedPassportElementBankStatement { @@ -579,34 +312,6 @@ pub struct EncryptedPassportElementBankStatement { pub translation: Option>, } -impl EncryptedPassportElementBankStatement { - pub fn new(files: F) -> Self - where - F: Into>, - { - Self { - files: files.into(), - translation: None, - } - } - - pub fn files

(mut self, val: P) -> Self - where - P: Into>, - { - self.files = val.into(); - self - } - - pub fn translation

(mut self, val: P) -> Self - where - P: Into>, - { - self.translation = Some(val.into()); - self - } -} - #[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct EncryptedPassportElementRentalAgreement { @@ -633,34 +338,6 @@ pub struct EncryptedPassportElementRentalAgreement { pub translation: Option>, } -impl EncryptedPassportElementRentalAgreement { - pub fn new(files: F) -> Self - where - F: Into>, - { - Self { - files: files.into(), - translation: None, - } - } - - pub fn files

(mut self, val: P) -> Self - where - P: Into>, - { - self.files = val.into(); - self - } - - pub fn translation

(mut self, val: P) -> Self - where - P: Into>, - { - self.translation = Some(val.into()); - self - } -} - #[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct EncryptedPassportElementPassportRegistration { @@ -687,34 +364,6 @@ pub struct EncryptedPassportElementPassportRegistration { pub translation: Option>, } -impl EncryptedPassportElementPassportRegistration { - pub fn new(files: F) -> Self - where - F: Into>, - { - Self { - files: files.into(), - translation: None, - } - } - - pub fn files

(mut self, val: P) -> Self - where - P: Into>, - { - self.files = val.into(); - self - } - - pub fn translation

(mut self, val: P) -> Self - where - P: Into>, - { - self.translation = Some(val.into()); - self - } -} - #[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct EncryptedPassportElementTemporaryRegistration { @@ -741,34 +390,6 @@ pub struct EncryptedPassportElementTemporaryRegistration { pub translation: Option>, } -impl EncryptedPassportElementTemporaryRegistration { - pub fn new(files: F) -> Self - where - F: Into>, - { - Self { - files: files.into(), - translation: None, - } - } - - pub fn files

(mut self, val: P) -> Self - where - P: Into>, - { - self.files = val.into(); - self - } - - pub fn translation

(mut self, val: P) -> Self - where - P: Into>, - { - self.translation = Some(val.into()); - self - } -} - #[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct EncryptedPassportElementPhoneNumber { @@ -777,47 +398,9 @@ pub struct EncryptedPassportElementPhoneNumber { pub phone_number: String, } -impl EncryptedPassportElementPhoneNumber { - pub fn new(phone_number: S) -> Self - where - S: Into, - { - Self { - phone_number: phone_number.into(), - } - } - - pub fn phone_number(mut self, val: S) -> Self - where - S: Into, - { - self.phone_number = val.into(); - self - } -} - #[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct EncryptedPassportElementEmail { /// User's verified email address, available only for `email` type. pub email: String, } - -impl EncryptedPassportElementEmail { - pub fn new(email: S) -> Self - where - S: Into, - { - Self { - email: email.into(), - } - } - - pub fn email(mut self, val: S) -> Self - where - S: Into, - { - self.email = val.into(); - self - } -} diff --git a/src/types/file.rs b/src/types/file.rs index a1eeeb75..82aa237e 100644 --- a/src/types/file.rs +++ b/src/types/file.rs @@ -30,48 +30,3 @@ pub struct File { /// crate::net::Download::download_file pub file_path: String, } - -impl File { - pub fn new(file_id: S1, file_unique_id: S2, file_size: u32, file_path: S3) -> Self - where - S1: Into, - S2: Into, - S3: Into, - { - Self { - file_id: file_id.into(), - file_unique_id: file_unique_id.into(), - file_size, - file_path: file_path.into(), - } - } - - 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 file_size(mut self, val: u32) -> Self { - self.file_size = val; - self - } - - pub fn file_path(mut self, val: S) -> Self - where - S: Into, - { - self.file_id = val.into(); - self - } -} diff --git a/src/types/force_reply.rs b/src/types/force_reply.rs index cb8ed997..462e47a5 100644 --- a/src/types/force_reply.rs +++ b/src/types/force_reply.rs @@ -29,11 +29,14 @@ pub struct ForceReply { } impl ForceReply { - pub fn new() -> Self { - Self::default() + pub const fn new() -> Self { + Self { + force_reply: True, + selective: None, + } } - pub fn selective(mut self, val: bool) -> Self { + pub const fn selective(mut self, val: bool) -> Self { self.selective = Some(val); self } diff --git a/src/types/game.rs b/src/types/game.rs index ca3f4e7d..fa9c5f33 100644 --- a/src/types/game.rs +++ b/src/types/game.rs @@ -39,66 +39,3 @@ pub struct Game { /// [@Botfather]: https://t.me/botfather pub animation: Option, } - -impl Game { - pub fn new(title: S1, description: S2, photo: P) -> Self - where - S1: Into, - S2: Into, - P: Into>, - { - Self { - title: title.into(), - description: description.into(), - photo: photo.into(), - text: None, - text_entities: None, - animation: None, - } - } - - pub fn title(mut self, val: S) -> Self - where - S: Into, - { - self.title = val.into(); - self - } - - pub fn description(mut self, val: S) -> Self - where - S: Into, - { - self.description = val.into(); - self - } - - pub fn photo

(mut self, val: P) -> Self - where - P: Into>, - { - self.photo = val.into(); - self - } - - pub fn text(mut self, val: S) -> Self - where - S: Into, - { - self.text = Some(val.into()); - self - } - - pub fn text_entities(mut self, val: T) -> Self - where - T: Into>, - { - self.text_entities = Some(val.into()); - self - } - - pub fn animation(mut self, val: Animation) -> Self { - self.animation = Some(val); - self - } -} diff --git a/src/types/game_high_score.rs b/src/types/game_high_score.rs index 57ac5719..059686c1 100644 --- a/src/types/game_high_score.rs +++ b/src/types/game_high_score.rs @@ -16,28 +16,3 @@ pub struct GameHighScore { /// Score. pub score: u32, } - -impl GameHighScore { - pub fn new(position: u32, user: User, score: u32) -> Self { - Self { - position, - user, - score, - } - } - - pub fn position(mut self, val: u32) -> Self { - self.position = val; - self - } - - pub fn user(mut self, val: User) -> Self { - self.user = val; - self - } - - pub fn score(mut self, val: u32) -> Self { - self.score = val; - self - } -} diff --git a/src/types/input_media.rs b/src/types/input_media.rs index a5d3dd84..2cdb4637 100644 --- a/src/types/input_media.rs +++ b/src/types/input_media.rs @@ -38,7 +38,7 @@ pub struct InputMediaPhoto { } impl InputMediaPhoto { - pub fn new(media: InputFile) -> Self { + pub const fn new(media: InputFile) -> Self { Self { media, caption: None, @@ -59,7 +59,7 @@ impl InputMediaPhoto { self } - pub fn parse_mode(mut self, val: ParseMode) -> Self { + pub const fn parse_mode(mut self, val: ParseMode) -> Self { self.parse_mode = Some(val); self } @@ -106,7 +106,7 @@ pub struct InputMediaVideo { } impl InputMediaVideo { - pub fn new(media: InputFile) -> Self { + pub const fn new(media: InputFile) -> Self { Self { media, thumb: None, @@ -137,27 +137,27 @@ impl InputMediaVideo { self } - pub fn parse_mode(mut self, val: ParseMode) -> Self { + pub const fn parse_mode(mut self, val: ParseMode) -> Self { self.parse_mode = Some(val); self } - pub fn width(mut self, val: u16) -> Self { + pub const fn width(mut self, val: u16) -> Self { self.width = Some(val); self } - pub fn height(mut self, val: u16) -> Self { + pub const fn height(mut self, val: u16) -> Self { self.height = Some(val); self } - pub fn duration(mut self, val: u16) -> Self { + pub const fn duration(mut self, val: u16) -> Self { self.duration = Some(val); self } - pub fn supports_streaming(mut self, val: bool) -> Self { + pub const fn supports_streaming(mut self, val: bool) -> Self { self.supports_streaming = Some(val); self } @@ -202,7 +202,7 @@ pub struct InputMediaAnimation { } impl InputMediaAnimation { - pub fn new(media: InputFile) -> Self { + pub const fn new(media: InputFile) -> Self { Self { media, thumb: None, @@ -232,22 +232,22 @@ impl InputMediaAnimation { self } - pub fn parse_mode(mut self, val: ParseMode) -> Self { + pub const fn parse_mode(mut self, val: ParseMode) -> Self { self.parse_mode = Some(val); self } - pub fn width(mut self, val: u16) -> Self { + pub const fn width(mut self, val: u16) -> Self { self.width = Some(val); self } - pub fn height(mut self, val: u16) -> Self { + pub const fn height(mut self, val: u16) -> Self { self.height = Some(val); self } - pub fn duration(mut self, val: u16) -> Self { + pub const fn duration(mut self, val: u16) -> Self { self.duration = Some(val); self } @@ -291,7 +291,7 @@ pub struct InputMediaAudio { } impl InputMediaAudio { - pub fn new(media: InputFile) -> Self { + pub const fn new(media: InputFile) -> Self { Self { media, thumb: None, @@ -321,12 +321,12 @@ impl InputMediaAudio { self } - pub fn parse_mode(mut self, val: ParseMode) -> Self { + pub const fn parse_mode(mut self, val: ParseMode) -> Self { self.parse_mode = Some(val); self } - pub fn duration(mut self, val: u16) -> Self { + pub const fn duration(mut self, val: u16) -> Self { self.duration = Some(val); self } @@ -377,7 +377,7 @@ pub struct InputMediaDocument { } impl InputMediaDocument { - pub fn new(media: InputFile) -> Self { + pub const fn new(media: InputFile) -> Self { Self { media, thumb: None, @@ -386,6 +386,11 @@ impl InputMediaDocument { } } + pub fn media(mut self, val: InputFile) -> Self { + self.media = val; + self + } + pub fn thumb(mut self, val: InputFile) -> Self { self.thumb = Some(val); self @@ -399,7 +404,7 @@ impl InputMediaDocument { self } - pub fn parse_mode(mut self, val: ParseMode) -> Self { + pub const fn parse_mode(mut self, val: ParseMode) -> Self { self.parse_mode = Some(val); self } diff --git a/src/types/input_message_content.rs b/src/types/input_message_content.rs index 169fdd1c..f8cae294 100644 --- a/src/types/input_message_content.rs +++ b/src/types/input_message_content.rs @@ -82,7 +82,7 @@ pub struct InputMessageContentLocation { } impl InputMessageContentLocation { - pub fn new(latitude: f64, longitude: f64) -> Self { + pub const fn new(latitude: f64, longitude: f64) -> Self { Self { latitude, longitude, @@ -90,17 +90,17 @@ impl InputMessageContentLocation { } } - pub fn latitude(mut self, val: f64) -> Self { + pub const fn latitude(mut self, val: f64) -> Self { self.latitude = val; self } - pub fn longitude(mut self, val: f64) -> Self { + pub const fn longitude(mut self, val: f64) -> Self { self.longitude = val; self } - pub fn live_period(mut self, val: u32) -> Self { + pub const fn live_period(mut self, val: u32) -> Self { self.live_period = Some(val); self } diff --git a/src/types/invoice.rs b/src/types/invoice.rs index cb4383e6..b9f2f5b6 100644 --- a/src/types/invoice.rs +++ b/src/types/invoice.rs @@ -27,64 +27,3 @@ pub struct Invoice { /// [`currencies.json`]: https://core.telegram.org/bots/payments/currencies.json pub total_amount: i32, } - -impl Invoice { - pub fn new( - title: S1, - description: S2, - start_parameter: S3, - currency: S4, - total_amount: i32, - ) -> Self - where - S1: Into, - S2: Into, - S3: Into, - S4: Into, - { - Self { - title: title.into(), - description: description.into(), - start_parameter: start_parameter.into(), - currency: currency.into(), - total_amount, - } - } - - pub fn title(mut self, val: S) -> Self - where - S: Into, - { - self.title = val.into(); - self - } - - pub fn description(mut self, val: S) -> Self - where - S: Into, - { - self.description = val.into(); - self - } - - pub fn start_parameter(mut self, val: S) -> Self - where - S: Into, - { - self.start_parameter = val.into(); - self - } - - pub fn currency(mut self, val: S) -> Self - where - S: Into, - { - self.currency = val.into(); - self - } - - pub fn total_amount(mut self, val: i32) -> Self { - self.total_amount = val; - self - } -} diff --git a/src/types/keyboard_button.rs b/src/types/keyboard_button.rs index f25f4f52..2cefc957 100644 --- a/src/types/keyboard_button.rs +++ b/src/types/keyboard_button.rs @@ -37,9 +37,9 @@ impl KeyboardButton { pub fn request(mut self, val: T) -> Self where - T: Into>, + T: Into, { - self.request = val.into(); + self.request = Some(val.into()); self } } diff --git a/src/types/location.rs b/src/types/location.rs index 7fd1a71d..c624d638 100644 --- a/src/types/location.rs +++ b/src/types/location.rs @@ -9,22 +9,3 @@ pub struct Location { /// Latitude as defined by sender. pub latitude: f64, } - -impl Location { - pub fn new(longitude: f64, latitude: f64) -> Self { - Self { - longitude, - latitude, - } - } - - pub fn latitude(mut self, val: f64) -> Self { - self.latitude = val; - self - } - - pub fn longitude(mut self, val: f64) -> Self { - self.longitude = val; - self - } -} diff --git a/src/types/me.rs b/src/types/me.rs index 3f7d1c32..ddb699dc 100644 --- a/src/types/me.rs +++ b/src/types/me.rs @@ -20,42 +20,3 @@ pub struct Me { /// `true`, if the bot supports inline queries. pub supports_inline_queries: bool, } - -impl Me { - pub fn new( - user: User, - can_join_groups: bool, - can_read_all_group_messages: bool, - supports_inline_queries: bool, - ) -> Self { - Self { - user, - can_join_groups, - can_read_all_group_messages, - supports_inline_queries, - } - } - - pub fn user(mut self, val: User) -> Self { - self.user = val; - self - } - - #[warn(clippy::wrong_self_convention)] - pub fn can_join_groups(mut self, val: bool) -> Self { - self.can_join_groups = val; - self - } - - #[warn(clippy::wrong_self_convention)] - pub fn can_read_all_group_messages(mut self, val: bool) -> Self { - self.can_read_all_group_messages = val; - self - } - - #[warn(clippy::wrong_self_convention)] - pub fn supports_inline_queries(mut self, val: bool) -> Self { - self.supports_inline_queries = val; - self - } -} diff --git a/src/types/message.rs b/src/types/message.rs index 1e13e158..bc8ddb32 100644 --- a/src/types/message.rs +++ b/src/types/message.rs @@ -31,43 +31,6 @@ pub struct Message { pub kind: MessageKind, } -impl Message { - pub fn new(id: i32, date: i32, chat: Chat, kind: MessageKind) -> Self { - Self { - id, - date, - chat, - kind, - via_bot: None, - } - } - - pub fn id(mut self, val: i32) -> Self { - self.id = val; - self - } - - pub fn date(mut self, val: i32) -> Self { - self.date = val; - self - } - - pub fn chat(mut self, val: Chat) -> Self { - self.chat = val; - self - } - - pub fn kind(mut self, val: MessageKind) -> Self { - self.kind = val; - self - } - - pub fn via_bot(mut self, val: User) -> Self { - self.via_bot = Some(val); - self - } -} - #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[serde(untagged)] pub enum MessageKind { @@ -109,43 +72,6 @@ pub struct MessageCommon { pub reply_markup: Option, } -impl MessageCommon { - pub fn new(forward_kind: ForwardKind, media_kind: MediaKind) -> Self { - Self { - from: None, - forward_kind, - edit_date: None, - media_kind, - reply_markup: None, - } - } - - pub fn from(mut self, val: User) -> Self { - self.from = Some(val); - self - } - - pub fn forward_kind(mut self, val: ForwardKind) -> Self { - self.forward_kind = val; - self - } - - pub fn edit_date(mut self, val: i32) -> Self { - self.edit_date = Some(val); - self - } - - pub fn media_kind(mut self, val: MediaKind) -> Self { - self.media_kind = val; - self - } - - pub fn reply_markup(mut self, val: InlineKeyboardMarkup) -> Self { - self.reply_markup = Some(val); - self - } -} - #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct MessageNewChatMembers { /// New members that were added to the group or supergroup and @@ -154,25 +80,6 @@ pub struct MessageNewChatMembers { pub new_chat_members: Vec, } -impl MessageNewChatMembers { - pub fn new(new_chat_members: N) -> Self - where - N: Into>, - { - Self { - new_chat_members: new_chat_members.into(), - } - } - - pub fn new_chat_members(mut self, val: N) -> Self - where - N: Into>, - { - self.new_chat_members = val.into(); - self - } -} - #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct MessageLeftChatMember { /// A member was removed from the group, information about them (this @@ -180,99 +87,30 @@ pub struct MessageLeftChatMember { pub left_chat_member: User, } -impl MessageLeftChatMember { - pub fn new(left_chat_member: N) -> Self - where - N: Into, - { - Self { - left_chat_member: left_chat_member.into(), - } - } - - pub fn left_chat_member(mut self, val: N) -> Self - where - N: Into, - { - self.left_chat_member = val.into(); - self - } -} - #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct MessageNewChatTitle { /// A chat title was changed to this value. pub new_chat_title: String, } -impl MessageNewChatTitle { - pub fn new(new_chat_title: N) -> Self - where - N: Into, - { - Self { - new_chat_title: new_chat_title.into(), - } - } - - pub fn new_chat_title(mut self, val: N) -> Self - where - N: Into, - { - self.new_chat_title = val.into(); - self - } -} - #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct MessageNewChatPhoto { /// A chat photo was change to this value. pub new_chat_photo: Vec, } -impl MessageNewChatPhoto { - pub fn new(new_chat_photo: N) -> Self - where - N: Into>, - { - Self { - new_chat_photo: new_chat_photo.into(), - } - } - - pub fn new_chat_photo(mut self, val: N) -> Self - where - N: Into>, - { - self.new_chat_photo = val.into(); - self - } -} - #[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)] pub struct MessageDeleteChatPhoto { /// Service message: the chat photo was deleted. pub delete_chat_photo: True, } -impl MessageDeleteChatPhoto { - pub fn new() -> Self { - Self::default() - } -} - #[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)] pub struct MessageGroupChatCreated { /// Service message: the group has been created. pub group_chat_created: True, } -impl MessageGroupChatCreated { - pub fn new() -> Self { - Self::default() - } -} - #[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)] pub struct MessageSupergroupChatCreated { /// Service message: the supergroup has been created. This field can‘t @@ -283,12 +121,6 @@ pub struct MessageSupergroupChatCreated { pub supergroup_chat_created: True, } -impl MessageSupergroupChatCreated { - pub fn new() -> Self { - Self::default() - } -} - #[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)] pub struct MessageChannelChatCreated { /// Service message: the channel has been created. This field can‘t be @@ -299,12 +131,6 @@ pub struct MessageChannelChatCreated { pub channel_chat_created: True, } -impl MessageChannelChatCreated { - pub fn new() -> Self { - Self::default() - } -} - #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct MessageMigrate { /// The group has been migrated to a supergroup with the specified @@ -324,25 +150,6 @@ pub struct MessageMigrate { pub migrate_from_chat_id: i64, } -impl MessageMigrate { - pub fn new(migrate_to_chat_id: i64, migrate_from_chat_id: i64) -> Self { - Self { - migrate_to_chat_id, - migrate_from_chat_id, - } - } - - pub fn migrate_to_chat_id(mut self, val: i64) -> Self { - self.migrate_to_chat_id = val; - self - } - - pub fn migrate_from_chat_id(mut self, val: i64) -> Self { - self.migrate_from_chat_id = val; - self - } -} - #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct MessagePinned { /// Specified message was pinned. Note that the Message object in this @@ -352,19 +159,6 @@ pub struct MessagePinned { pub pinned: Box, } -impl MessagePinned { - pub fn new(pinned: Message) -> Self { - Self { - pinned: Box::new(pinned), - } - } - - pub fn pinned(mut self, val: Message) -> Self { - self.pinned = Box::new(val); - self - } -} - #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct MessageInvoice { /// Message is an invoice for a [payment], information about the @@ -375,17 +169,6 @@ pub struct MessageInvoice { pub invoice: Invoice, } -impl MessageInvoice { - pub fn new(invoice: Invoice) -> Self { - Self { invoice } - } - - pub fn invoice(mut self, val: Invoice) -> Self { - self.invoice = val; - self - } -} - #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct MessageSuccessfulPayment { /// Message is a service message about a successful payment, @@ -395,17 +178,6 @@ pub struct MessageSuccessfulPayment { pub successful_payment: SuccessfulPayment, } -impl MessageSuccessfulPayment { - pub fn new(successful_payment: SuccessfulPayment) -> Self { - Self { successful_payment } - } - - pub fn successful_payment(mut self, val: SuccessfulPayment) -> Self { - self.successful_payment = val; - self - } -} - #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct MessageConnectedWebsite { /// The domain name of the website on which the user has logged in. @@ -415,42 +187,12 @@ pub struct MessageConnectedWebsite { pub connected_website: String, } -impl MessageConnectedWebsite { - pub fn new(connected_website: S) -> Self - where - S: Into, - { - Self { - connected_website: connected_website.into(), - } - } - - pub fn connected_website(mut self, val: S) -> Self - where - S: Into, - { - self.connected_website = val.into(); - self - } -} - #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct MessagePassportData { /// Telegram Passport data. pub passport_data: PassportData, } -impl MessagePassportData { - pub fn new(passport_data: PassportData) -> Self { - Self { passport_data } - } - - pub fn passport_data(mut self, val: PassportData) -> Self { - self.passport_data = val; - self - } -} - #[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub enum ForwardedFrom { #[serde(rename = "forward_from")] @@ -482,40 +224,6 @@ pub struct ForwardChannel { pub signature: Option, } -impl ForwardChannel { - pub fn new(date: i32, chat: Chat, message_id: i32) -> Self { - Self { - date, - chat, - message_id, - signature: None, - } - } - - pub fn date(mut self, val: i32) -> Self { - self.date = val; - self - } - - pub fn chat(mut self, val: Chat) -> Self { - self.chat = val; - self - } - - pub fn message_id(mut self, val: i32) -> Self { - self.message_id = val; - self - } - - pub fn signature(mut self, val: S) -> Self - where - S: Into, - { - self.signature = Some(val.into()); - self - } -} - #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct ForwardNonChannel { #[serde(rename = "forward_date")] @@ -525,38 +233,11 @@ pub struct ForwardNonChannel { pub from: ForwardedFrom, } -impl ForwardNonChannel { - pub fn new(date: i32, from: ForwardedFrom) -> Self { - Self { date, from } - } - - pub fn date(mut self, val: i32) -> Self { - self.date = val; - self - } - - pub fn from(mut self, val: ForwardedFrom) -> Self { - self.from = val; - self - } -} - #[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)] pub struct ForwardOrigin { pub reply_to_message: Option>, } -impl ForwardOrigin { - pub fn new() -> Self { - Self::default() - } - - pub fn reply_to_message(mut self, val: Message) -> Self { - self.reply_to_message = Some(Box::new(val)); - self - } -} - #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[serde(untagged)] pub enum MediaKind { @@ -597,41 +278,6 @@ pub struct MediaAnimation { pub caption_entities: Vec, } -impl MediaAnimation { - pub fn new(animation: Animation, caption_entities: CE) -> Self - where - CE: Into>, - { - Self { - animation, - document: (), - caption: None, - caption_entities: caption_entities.into(), - } - } - - pub fn animation(mut self, val: Animation) -> Self { - self.animation = val; - self - } - - pub fn caption(mut self, val: S) -> Self - where - S: Into, - { - self.caption = Some(val.into()); - self - } - - pub fn caption_entities(mut self, val: CE) -> Self - where - CE: Into>, - { - self.caption_entities = val.into(); - self - } -} - #[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct MediaAudio { @@ -647,57 +293,12 @@ pub struct MediaAudio { pub caption_entities: Vec, } -impl MediaAudio { - pub fn new(audio: Audio, caption_entities: CE) -> Self - where - CE: Into>, - { - Self { - audio, - caption: None, - caption_entities: caption_entities.into(), - } - } - - pub fn audio(mut self, val: Audio) -> Self { - self.audio = val; - self - } - - pub fn caption(mut self, val: S) -> Self - where - S: Into, - { - self.caption = Some(val.into()); - self - } - - pub fn caption_entities(mut self, val: CE) -> Self - where - CE: Into>, - { - self.caption_entities = val.into(); - self - } -} - #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct MediaContact { /// Message is a shared contact, information about the contact. contact: Contact, } -impl MediaContact { - pub fn new(contact: Contact) -> Self { - Self { contact } - } - - pub fn contact(mut self, val: Contact) -> Self { - self.contact = val; - self - } -} - #[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct MediaDocument { @@ -713,40 +314,6 @@ pub struct MediaDocument { pub caption_entities: Vec, } -impl MediaDocument { - pub fn new(document: Document, caption_entities: CE) -> Self - where - CE: Into>, - { - Self { - document, - caption: None, - caption_entities: caption_entities.into(), - } - } - - pub fn document(mut self, val: Document) -> Self { - self.document = val; - self - } - - pub fn caption(mut self, val: S) -> Self - where - S: Into, - { - self.caption = Some(val.into()); - self - } - - pub fn caption_entities(mut self, val: CE) -> Self - where - CE: Into>, - { - self.caption_entities = val.into(); - self - } -} - #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct MediaGame { /// Message is a game, information about the game. [More @@ -756,34 +323,12 @@ pub struct MediaGame { pub game: Game, } -impl MediaGame { - pub fn new(game: Game) -> Self { - Self { game } - } - - pub fn game(mut self, val: Game) -> Self { - self.game = val; - self - } -} - #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct MediaLocation { /// Message is a shared location, information about the location. pub location: Location, } -impl MediaLocation { - pub fn new(location: Location) -> Self { - Self { location } - } - - pub fn location(mut self, val: Location) -> Self { - self.location = val; - self - } -} - #[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct MediaPhoto { @@ -803,87 +348,18 @@ pub struct MediaPhoto { pub media_group_id: Option, } -impl MediaPhoto { - pub fn new(photo: P, caption_entities: CE) -> Self - where - P: Into>, - CE: Into>, - { - Self { - photo: photo.into(), - caption: None, - caption_entities: caption_entities.into(), - media_group_id: None, - } - } - - pub fn photo

(mut self, val: P) -> Self - where - P: Into>, - { - self.photo = val.into(); - self - } - - pub fn caption(mut self, val: S) -> Self - where - S: Into, - { - self.caption = Some(val.into()); - self - } - - pub fn caption_entities(mut self, val: CE) -> Self - where - CE: Into>, - { - self.caption_entities = val.into(); - self - } - - pub fn media_group_id(mut self, val: S) -> Self - where - S: Into, - { - self.media_group_id = Some(val.into()); - self - } -} - #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct MediaPoll { /// Message is a native poll, information about the poll. pub poll: Poll, } -impl MediaPoll { - pub fn new(poll: Poll) -> Self { - Self { poll } - } - - pub fn poll(mut self, val: Poll) -> Self { - self.poll = val; - self - } -} - #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct MediaSticker { /// Message is a sticker, information about the sticker. pub sticker: Sticker, } -impl MediaSticker { - pub fn new(sticker: Sticker) -> Self { - Self { sticker } - } - - pub fn poll(mut self, val: Sticker) -> Self { - self.sticker = val; - self - } -} - #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct MediaText { /// For text messages, the actual UTF-8 text of the message, 0-4096 @@ -896,35 +372,6 @@ pub struct MediaText { pub entities: Vec, } -impl MediaText { - pub fn new(text: S, entities: E) -> Self - where - S: Into, - E: Into>, - { - Self { - text: text.into(), - entities: entities.into(), - } - } - - pub fn text(mut self, val: S) -> Self - where - S: Into, - { - self.text = val.into(); - self - } - - pub fn entities(mut self, val: CE) -> Self - where - CE: Into>, - { - self.entities = val.into(); - self - } -} - #[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct MediaVideo { @@ -944,49 +391,6 @@ pub struct MediaVideo { pub media_group_id: Option, } -impl MediaVideo { - pub fn new(video: Video, caption_entities: CE) -> Self - where - CE: Into>, - { - Self { - video, - caption: None, - caption_entities: caption_entities.into(), - media_group_id: None, - } - } - - pub fn video(mut self, val: Video) -> Self { - self.video = val; - self - } - - pub fn caption(mut self, val: S) -> Self - where - S: Into, - { - self.caption = Some(val.into()); - self - } - - pub fn caption_entities(mut self, val: CE) -> Self - where - CE: Into>, - { - self.caption_entities = val.into(); - self - } - - pub fn media_group_id(mut self, val: S) -> Self - where - S: Into, - { - self.media_group_id = Some(val.into()); - self - } -} - #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct MediaVideoNote { /// Message is a [video note], information about the video message. @@ -995,17 +399,6 @@ pub struct MediaVideoNote { pub video_note: VideoNote, } -impl MediaVideoNote { - pub fn new(video_note: VideoNote) -> Self { - Self { video_note } - } - - pub fn video_note(mut self, val: VideoNote) -> Self { - self.video_note = val; - self - } -} - #[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct MediaVoice { @@ -1021,57 +414,12 @@ pub struct MediaVoice { pub caption_entities: Vec, } -impl MediaVoice { - pub fn new(voice: Voice, caption_entities: CE) -> Self - where - CE: Into>, - { - Self { - voice, - caption: None, - caption_entities: caption_entities.into(), - } - } - - pub fn voice(mut self, val: Voice) -> Self { - self.voice = val; - self - } - - pub fn caption(mut self, val: S) -> Self - where - S: Into, - { - self.caption = Some(val.into()); - self - } - - pub fn caption_entities(mut self, val: CE) -> Self - where - CE: Into>, - { - self.caption_entities = val.into(); - self - } -} - #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct MediaVenue { /// Message is a venue, information about the venue. pub venue: Venue, } -impl MediaVenue { - pub fn new(venue: Venue) -> Self { - Self { venue } - } - - pub fn venue(mut self, val: Venue) -> Self { - self.venue = val; - self - } -} - #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct MessageDice { /// Message is a dice with random value from 1 to 6. diff --git a/src/types/message_entity.rs b/src/types/message_entity.rs index 79876cf0..fbd57216 100644 --- a/src/types/message_entity.rs +++ b/src/types/message_entity.rs @@ -20,7 +20,7 @@ pub struct MessageEntity { } impl MessageEntity { - pub fn new(kind: MessageEntityKind, offset: usize, length: usize) -> Self { + pub const fn new(kind: MessageEntityKind, offset: usize, length: usize) -> Self { Self { kind, offset, @@ -33,12 +33,12 @@ impl MessageEntity { self } - pub fn offset(mut self, val: usize) -> Self { + pub const fn offset(mut self, val: usize) -> Self { self.offset = val; self } - pub fn length(mut self, val: usize) -> Self { + pub const fn length(mut self, val: usize) -> Self { self.length = val; self } diff --git a/src/types/order_info.rs b/src/types/order_info.rs index 5dca09d7..e5b35bbc 100644 --- a/src/types/order_info.rs +++ b/src/types/order_info.rs @@ -19,53 +19,3 @@ pub struct OrderInfo { /// User's shipping address. pub shipping_address: ShippingAddress, } - -impl OrderInfo { - pub fn new( - name: S1, - phone_number: S2, - email: S3, - shipping_address: ShippingAddress, - ) -> Self - where - S1: Into, - S2: Into, - S3: Into, - { - Self { - name: name.into(), - phone_number: phone_number.into(), - email: email.into(), - shipping_address, - } - } - - pub fn name(mut self, val: S) -> Self - where - S: Into, - { - self.name = val.into(); - self - } - - pub fn phone_number(mut self, val: S) -> Self - where - S: Into, - { - self.phone_number = val.into(); - self - } - - pub fn email(mut self, val: S) -> Self - where - S: Into, - { - self.email = val.into(); - self - } - - pub fn shipping_address(mut self, val: ShippingAddress) -> Self { - self.shipping_address = val; - self - } -} diff --git a/src/types/passport_data.rs b/src/types/passport_data.rs index c34f97ea..5e548f57 100644 --- a/src/types/passport_data.rs +++ b/src/types/passport_data.rs @@ -15,28 +15,3 @@ pub struct PassportData { /// Encrypted credentials required to decrypt the data. pub credentials: EncryptedCredentials, } - -impl PassportData { - pub fn new(data: E, credentials: EncryptedCredentials) -> Self - where - E: Into>, - { - Self { - data: data.into(), - credentials, - } - } - - pub fn data(mut self, val: E) -> Self - where - E: Into>, - { - self.data = val.into(); - self - } - - pub fn credentials(mut self, val: EncryptedCredentials) -> Self { - self.credentials = val; - self - } -} diff --git a/src/types/passport_file.rs b/src/types/passport_file.rs index f5c68741..18f1a5d4 100644 --- a/src/types/passport_file.rs +++ b/src/types/passport_file.rs @@ -22,44 +22,3 @@ pub struct PassportFile { /// Unix time when the file was uploaded. pub file_date: u64, } - -impl PassportFile { - pub fn new(file_id: S1, file_unique_id: S2, file_size: u64, file_date: u64) -> Self - where - S1: Into, - S2: Into, - { - Self { - file_id: file_id.into(), - file_unique_id: file_unique_id.into(), - file_size, - file_date, - } - } - - 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 file_size(mut self, val: u64) -> Self { - self.file_size = val; - self - } - - pub fn file_date(mut self, val: u64) -> Self { - self.file_date = val; - self - } -} diff --git a/src/types/photo_size.rs b/src/types/photo_size.rs index 91e05639..44ddfe32 100644 --- a/src/types/photo_size.rs +++ b/src/types/photo_size.rs @@ -25,53 +25,6 @@ pub struct PhotoSize { pub file_size: Option, } -impl PhotoSize { - pub fn new(file_id: S1, file_unique_id: S2, width: i32, height: i32) -> Self - where - S1: Into, - S2: Into, - { - Self { - file_id: file_id.into(), - file_unique_id: file_unique_id.into(), - width, - height, - 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 width(mut self, val: i32) -> Self { - self.width = val; - self - } - - pub fn height(mut self, val: i32) -> Self { - self.height = val; - self - } - - pub fn file_size(mut self, val: u32) -> Self { - self.file_size = Some(val); - self - } -} - #[cfg(test)] mod tests { use super::*; diff --git a/src/types/poll.rs b/src/types/poll.rs index 8176aa5b..23bb9409 100644 --- a/src/types/poll.rs +++ b/src/types/poll.rs @@ -46,128 +46,11 @@ pub struct Poll { pub explanation_entities: Option>, /// Amount of time in seconds the poll will be active after creation. - open_period: Option, + pub open_period: Option, /// Point in time (Unix timestamp) when the poll will be automatically /// closed. - close_date: Option, -} - -impl Poll { - #[allow(clippy::too_many_arguments)] - pub fn new( - id: S1, - question: S2, - options: O, - is_closed: bool, - total_voter_count: i32, - is_anonymous: bool, - poll_type: PollType, - allows_multiple_answers: bool, - ) -> Self - where - S1: Into, - S2: Into, - O: Into>, - { - Self { - id: id.into(), - question: question.into(), - options: options.into(), - is_closed, - total_voter_count, - is_anonymous, - poll_type, - allows_multiple_answers, - correct_option_id: None, - explanation: None, - explanation_entities: None, - open_period: None, - close_date: None, - } - } - - pub fn id(mut self, val: S) -> Self - where - S: Into, - { - self.id = val.into(); - self - } - - pub fn question(mut self, val: S) -> Self - where - S: Into, - { - self.question = val.into(); - self - } - - pub fn options

(mut self, val: P) -> Self - where - P: Into>, - { - self.options = val.into(); - self - } - - #[allow(clippy::wrong_self_convention)] - pub fn is_closed(mut self, val: bool) -> Self { - self.is_closed = val; - self - } - - pub fn total_voter_count(mut self, val: i32) -> Self { - self.total_voter_count = val; - self - } - - #[allow(clippy::wrong_self_convention)] - pub fn is_anonymous(mut self, val: bool) -> Self { - self.is_anonymous = val; - self - } - - pub fn poll_type(mut self, val: PollType) -> Self { - self.poll_type = val; - self - } - - pub fn allows_multiple_answers(mut self, val: bool) -> Self { - self.allows_multiple_answers = val; - self - } - - pub fn correct_option_id(mut self, val: i32) -> Self { - self.correct_option_id = Some(val); - self - } - - pub fn explanation(mut self, val: S) -> Self - where - S: Into, - { - self.explanation = Some(val.into()); - self - } - - pub fn explanation_entities(mut self, val: S) -> Self - where - S: Into>, - { - self.explanation_entities = Some(val.into()); - self - } - - pub fn open_period(mut self, val: i32) -> Self { - self.open_period = Some(val); - self - } - - pub fn close_date(mut self, val: i32) -> Self { - self.close_date = Some(val); - self - } + pub close_date: Option, } /// This object contains information about one answer option in a poll. @@ -182,31 +65,6 @@ pub struct PollOption { pub voter_count: i32, } -impl PollOption { - pub fn new(text: S, voter_count: i32) -> Self - where - S: Into, - { - Self { - text: text.into(), - voter_count, - } - } - - pub fn text(mut self, val: S) -> Self - where - S: Into, - { - self.text = val.into(); - self - } - - pub fn voter_count(mut self, val: i32) -> Self { - self.voter_count = val; - self - } -} - #[cfg(test)] mod tests { use super::*; diff --git a/src/types/poll_answer.rs b/src/types/poll_answer.rs index befeb420..b8f26968 100644 --- a/src/types/poll_answer.rs +++ b/src/types/poll_answer.rs @@ -14,38 +14,3 @@ pub struct PollAnswer { /// May be empty if the user retracted their vote. pub option_ids: Vec, } - -impl PollAnswer { - pub fn new(poll_id: S, user: User, option_ids: O) -> Self - where - S: Into, - O: Into>, - { - Self { - poll_id: poll_id.into(), - user, - option_ids: option_ids.into(), - } - } - - pub fn poll_id(mut self, val: S) -> Self - where - S: Into, - { - self.poll_id = val.into(); - self - } - - pub fn user(mut self, val: User) -> Self { - self.user = val; - self - } - - pub fn option_ids(mut self, val: S) -> Self - where - S: Into>, - { - self.option_ids = val.into(); - self - } -} diff --git a/src/types/pre_checkout_query.rs b/src/types/pre_checkout_query.rs index 6b03f084..172e5e8f 100644 --- a/src/types/pre_checkout_query.rs +++ b/src/types/pre_checkout_query.rs @@ -37,71 +37,3 @@ pub struct PreCheckoutQuery { /// Order info provided by the user. pub order_info: Option, } - -impl PreCheckoutQuery { - pub fn new( - id: S1, - from: User, - currency: Currency, - total_amount: i32, - invoice_payload: S2, - ) -> Self - where - S1: Into, - S2: Into, - { - Self { - id: id.into(), - from, - currency, - total_amount, - invoice_payload: invoice_payload.into(), - shipping_option_id: None, - order_info: None, - } - } - - pub fn id(mut self, val: S) -> Self - where - S: Into, - { - self.id = val.into(); - self - } - - pub fn from(mut self, val: User) -> Self { - self.from = val; - self - } - - pub fn currency(mut self, val: Currency) -> Self { - self.currency = val; - self - } - - pub fn total_amount(mut self, val: i32) -> Self { - self.total_amount = val; - self - } - - pub fn invoice_payload(mut self, val: S) -> Self - where - S: Into, - { - self.invoice_payload = val.into(); - self - } - - pub fn shipping_option_id(mut self, val: S) -> Self - where - S: Into, - { - self.shipping_option_id = Some(val.into()); - self - } - - pub fn order_info(mut self, val: OrderInfo) -> Self { - self.order_info = Some(val); - self - } -} diff --git a/src/types/reply_keyboard_remove.rs b/src/types/reply_keyboard_remove.rs index 7a4d1643..2e9c81f6 100644 --- a/src/types/reply_keyboard_remove.rs +++ b/src/types/reply_keyboard_remove.rs @@ -37,15 +37,15 @@ pub struct ReplyKeyboardRemove { } impl ReplyKeyboardRemove { - pub fn new() -> Self { - Self::default() + pub const fn new() -> Self { + Self { + remove_keyboard: True, + selective: None, + } } - pub fn selective(mut self, val: T) -> Self - where - T: Into, - { - self.selective = Some(val.into()); + pub const fn selective(mut self, val: bool) -> Self { + self.selective = Some(val); self } } diff --git a/src/types/shipping_address.rs b/src/types/shipping_address.rs index 95ae4825..478ad714 100644 --- a/src/types/shipping_address.rs +++ b/src/types/shipping_address.rs @@ -24,76 +24,3 @@ pub struct ShippingAddress { /// Address post code. pub post_code: String, } - -impl ShippingAddress { - pub fn new( - country_code: CountryCode, - - state: S1, - city: S2, - street_line1: S3, - street_line2: S4, - post_code: S5, - ) -> Self - where - S1: Into, - S2: Into, - S3: Into, - S4: Into, - S5: Into, - { - Self { - country_code, - state: state.into(), - city: city.into(), - street_line1: street_line1.into(), - street_line2: street_line2.into(), - post_code: post_code.into(), - } - } - - pub fn country_code(mut self, val: CountryCode) -> Self { - self.country_code = val; - self - } - - pub fn state(mut self, val: S) -> Self - where - S: Into, - { - self.state = val.into(); - self - } - - pub fn city(mut self, val: S) -> Self - where - S: Into, - { - self.city = val.into(); - self - } - - pub fn street_line1(mut self, val: S) -> Self - where - S: Into, - { - self.street_line1 = val.into(); - self - } - - pub fn street_line2(mut self, val: S) -> Self - where - S: Into, - { - self.street_line2 = val.into(); - self - } - - pub fn post_code(mut self, val: S) -> Self - where - S: Into, - { - self.post_code = val.into(); - self - } -} diff --git a/src/types/shipping_query.rs b/src/types/shipping_query.rs index 97b0fd27..f8df55d4 100644 --- a/src/types/shipping_query.rs +++ b/src/types/shipping_query.rs @@ -19,49 +19,3 @@ pub struct ShippingQuery { /// User specified shipping address. pub shipping_address: ShippingAddress, } - -impl ShippingQuery { - pub fn new( - id: S1, - from: User, - invoice_payload: S2, - shipping_address: ShippingAddress, - ) -> Self - where - S1: Into, - S2: Into, - { - Self { - id: id.into(), - from, - invoice_payload: invoice_payload.into(), - shipping_address, - } - } - - pub fn id(mut self, val: S) -> Self - where - S: Into, - { - self.id = val.into(); - self - } - - pub fn from(mut self, val: User) -> Self { - self.from = val; - self - } - - pub fn invoice_payload(mut self, val: S) -> Self - where - S: Into, - { - self.invoice_payload = val.into(); - self - } - - pub fn shipping_address(mut self, val: ShippingAddress) -> Self { - self.shipping_address = val; - self - } -} diff --git a/src/types/sticker.rs b/src/types/sticker.rs index 8851e8ef..235f774d 100644 --- a/src/types/sticker.rs +++ b/src/types/sticker.rs @@ -42,93 +42,3 @@ 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 - } -} diff --git a/src/types/sticker_set.rs b/src/types/sticker_set.rs index 0ffb4762..9fea1621 100644 --- a/src/types/sticker_set.rs +++ b/src/types/sticker_set.rs @@ -27,62 +27,3 @@ pub struct StickerSet { /// Sticker set thumbnail in the .WEBP or .TGS format. thumb: Option, } - -impl StickerSet { - pub fn new( - name: S1, - title: S2, - is_animated: bool, - contains_masks: bool, - stickers: St, - ) -> Self - where - S1: Into, - S2: Into, - St: Into>, - { - Self { - name: name.into(), - title: title.into(), - is_animated, - contains_masks, - stickers: stickers.into(), - thumb: None, - } - } - - pub fn name(mut self, val: S) -> Self - where - S: Into, - { - self.name = val.into(); - self - } - - pub fn title(mut self, val: S) -> Self - where - S: Into, - { - self.title = val.into(); - self - } - - #[allow(clippy::wrong_self_convention)] - pub fn is_animated(mut self, val: bool) -> Self { - self.is_animated = val; - self - } - - pub fn contains_masks(mut self, val: bool) -> Self { - self.contains_masks = val; - self - } - - pub fn stickers(mut self, val: S) -> Self - where - S: Into>, - { - self.stickers = val.into(); - self - } -} diff --git a/src/types/successful_payment.rs b/src/types/successful_payment.rs index 4f7e43b5..d38a36b5 100644 --- a/src/types/successful_payment.rs +++ b/src/types/successful_payment.rs @@ -37,75 +37,3 @@ pub struct SuccessfulPayment { /// Provider payment identifier. pub provider_payment_charge_id: String, } - -impl SuccessfulPayment { - pub fn new( - currency: Currency, - total_amount: i32, - invoice_payload: S1, - telegram_payment_charge_id: S2, - provider_payment_charge_id: S3, - ) -> Self - where - S1: Into, - S2: Into, - S3: Into, - { - Self { - currency, - total_amount, - invoice_payload: invoice_payload.into(), - shipping_option_id: None, - order_info: None, - telegram_payment_charge_id: telegram_payment_charge_id.into(), - provider_payment_charge_id: provider_payment_charge_id.into(), - } - } - - pub fn currency(mut self, val: Currency) -> Self { - self.currency = val; - self - } - - pub fn total_amount(mut self, val: i32) -> Self { - self.total_amount = val; - self - } - - pub fn invoice_payload(mut self, val: S) -> Self - where - S: Into, - { - self.invoice_payload = val.into(); - self - } - - pub fn shipping_option_id(mut self, val: S) -> Self - where - S: Into, - { - self.shipping_option_id = Some(val.into()); - self - } - - pub fn order_info(mut self, val: OrderInfo) -> Self { - self.order_info = Some(val); - self - } - - pub fn telegram_payment_charge_id(mut self, val: S) -> Self - where - S: Into, - { - self.telegram_payment_charge_id = val.into(); - self - } - - pub fn provider_payment_charge_id(mut self, val: S) -> Self - where - S: Into, - { - self.provider_payment_charge_id = val.into(); - self - } -} diff --git a/src/types/update.rs b/src/types/update.rs index 51caf7ba..4ebc5710 100644 --- a/src/types/update.rs +++ b/src/types/update.rs @@ -28,22 +28,6 @@ pub struct Update { pub kind: UpdateKind, } -impl Update { - pub fn new(id: i32, kind: UpdateKind) -> Self { - Self { id, kind } - } - - pub fn id(mut self, val: i32) -> Self { - self.id = val; - self - } - - pub fn kind(mut self, val: UpdateKind) -> Self { - self.kind = val; - self - } -} - #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "snake_case")] pub enum UpdateKind { diff --git a/src/types/user.rs b/src/types/user.rs index 7db4c14c..b575ef04 100644 --- a/src/types/user.rs +++ b/src/types/user.rs @@ -27,65 +27,6 @@ pub struct User { pub language_code: Option, } -impl User { - pub fn new(id: i32, is_bot: bool, first_name: S) -> Self - where - S: Into, - { - Self { - id, - is_bot, - first_name: first_name.into(), - last_name: None, - username: None, - language_code: None, - } - } - - pub fn id(mut self, val: i32) -> Self { - self.id = val; - self - } - - #[allow(clippy::wrong_self_convention)] - pub fn is_bot(mut self, val: bool) -> Self { - self.is_bot = val; - self - } - - pub fn first_name(mut self, val: S) -> Self - where - S: Into, - { - self.first_name = val.into(); - self - } - - pub fn last_name(mut self, val: S) -> Self - where - S: Into, - { - self.last_name = Some(val.into()); - self - } - - pub fn username(mut self, val: S) -> Self - where - S: Into, - { - self.username = Some(val.into()); - self - } - - pub fn language_code(mut self, val: S) -> Self - where - S: Into, - { - self.language_code = Some(val.into()); - self - } -} - impl User { pub fn full_name(&self) -> String { match &self.last_name { diff --git a/src/types/user_profile_photos.rs b/src/types/user_profile_photos.rs index 05dec195..ac0a9b5d 100644 --- a/src/types/user_profile_photos.rs +++ b/src/types/user_profile_photos.rs @@ -13,30 +13,3 @@ pub struct UserProfilePhotos { /// Requested profile pictures (in up to 4 sizes each). pub photos: Vec>, } - -impl UserProfilePhotos { - pub fn new(total_count: u32, photos: P1) -> Self - where - P1: Into>, - P2: Into>, - { - Self { - total_count, - photos: photos.into().into_iter().map(Into::into).collect(), - } - } - - pub fn total_count(mut self, val: u32) -> Self { - self.total_count = val; - self - } - - pub fn photos(mut self, val: P1) -> Self - where - P1: Into>, - P2: Into>, - { - self.photos = val.into().into_iter().map(Into::into).collect(); - self - } -} diff --git a/src/types/venue.rs b/src/types/venue.rs index d8891a44..afb0cc90 100644 --- a/src/types/venue.rs +++ b/src/types/venue.rs @@ -23,51 +23,3 @@ pub struct Venue { /// `food/icecream`.) pub foursquare_type: Option, } - -impl Venue { - pub fn new(location: Location, title: S1, address: S2) -> Self - where - S1: Into, - S2: Into, - { - Self { - location, - title: title.into(), - address: address.into(), - foursquare_id: None, - foursquare_type: None, - } - } - - pub fn title(mut self, val: S) -> Self - where - S: Into, - { - self.title = val.into(); - self - } - - pub fn address(mut self, val: S) -> Self - where - S: Into, - { - self.address = val.into(); - self - } - - pub fn foursquare_id(mut self, val: S) -> Self - where - S: Into, - { - self.foursquare_id = Some(val.into()); - self - } - - pub fn foursquare_type(mut self, val: S) -> Self - where - S: Into, - { - self.foursquare_type = Some(val.into()); - self - } -} diff --git a/src/types/video.rs b/src/types/video.rs index 1db5737f..bc8611ec 100644 --- a/src/types/video.rs +++ b/src/types/video.rs @@ -36,74 +36,3 @@ pub struct Video { /// File size. pub file_size: Option, } - -impl Video { - pub fn new( - file_id: S1, - file_unique_id: S2, - width: u32, - height: u32, - duration: u32, - ) -> Self - where - S1: Into, - S2: Into, - { - Self { - file_id: file_id.into(), - file_unique_id: file_unique_id.into(), - width, - height, - duration, - thumb: None, - mime_type: 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 width(mut self, val: u32) -> Self { - self.width = val; - self - } - - pub fn height(mut self, val: u32) -> Self { - self.height = 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 mime_type(mut self, val: Mime) -> Self { - self.mime_type = Some(val); - self - } - - pub fn file_size(mut self, val: u32) -> Self { - self.file_size = Some(val); - self - } -} diff --git a/src/types/video_note.rs b/src/types/video_note.rs index d8c9ab3f..9a751e20 100644 --- a/src/types/video_note.rs +++ b/src/types/video_note.rs @@ -33,56 +33,3 @@ 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 2fc7a5b9..7264b0c4 100644 --- a/src/types/voice.rs +++ b/src/types/voice.rs @@ -25,50 +25,3 @@ pub struct Voice { /// File size. pub file_size: Option, } - -impl Voice { - 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, - mime_type: 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 duration(mut self, val: u32) -> Self { - self.duration = val; - self - } - - pub fn mime_type(mut self, val: Mime) -> Self { - self.mime_type = Some(val); - self - } - - pub fn file_size(mut self, val: u64) -> Self { - self.file_size = Some(val); - self - } -} diff --git a/src/types/webhook_info.rs b/src/types/webhook_info.rs index aad1cefb..e7658381 100644 --- a/src/types/webhook_info.rs +++ b/src/types/webhook_info.rs @@ -32,66 +32,3 @@ pub struct WebhookInfo { /// types. pub allowed_updates: Option>, } - -impl WebhookInfo { - pub fn new(url: S, has_custom_certificate: bool, pending_update_count: u32) -> Self - where - S: Into, - { - Self { - url: url.into(), - has_custom_certificate, - pending_update_count, - last_error_date: None, - - last_error_message: None, - max_connections: None, - allowed_updates: None, - } - } - - pub fn url(mut self, val: S) -> Self - where - S: Into, - { - self.url = val.into(); - self - } - - pub fn has_custom_certificate(mut self, val: bool) -> Self { - self.has_custom_certificate = val; - self - } - - pub fn pending_update_count(mut self, val: u32) -> Self { - self.pending_update_count = val; - self - } - - pub fn last_error_date(mut self, val: u64) -> Self { - self.last_error_date = Some(val); - self - } - - pub fn last_error_message(mut self, val: S) -> Self - where - S: Into, - { - self.last_error_message = Some(val.into()); - self - } - - pub fn max_connections(mut self, val: u32) -> Self { - self.max_connections = Some(val); - self - } - - pub fn allowed_updates(mut self, val: A) -> Self - where - A: Into>, - S: Into, - { - self.allowed_updates = Some(val.into().into_iter().map(Into::into).collect()); - self - } -}