From 5124750be9a9a6276ab25d4cd893c83484eb36d2 Mon Sep 17 00:00:00 2001 From: Waffle Date: Tue, 17 Sep 2019 20:43:31 +0300 Subject: [PATCH] Replace `i64` with `i32` --- src/bot/mod.rs | 2 +- src/core/requests/edit_message_live_location.rs | 4 ++-- src/core/requests/forward_message.rs | 6 +++--- src/core/requests/send_audio.rs | 4 ++-- src/core/requests/send_location.rs | 4 ++-- src/core/requests/send_media_group.rs | 4 ++-- src/core/requests/send_message.rs | 4 ++-- src/core/requests/send_photo.rs | 4 ++-- src/core/types/contact.rs | 2 +- src/core/types/invoice.rs | 2 +- src/core/types/label_price.rs | 2 +- src/core/types/message.rs | 4 ++-- src/core/types/pre_checkout_query.rs | 2 +- src/core/types/response_parameters.rs | 2 +- src/core/types/send_invoice.rs | 13 +++++++------ src/core/types/successful_payment.rs | 2 +- src/core/types/user.rs | 2 +- 17 files changed, 32 insertions(+), 31 deletions(-) diff --git a/src/bot/mod.rs b/src/bot/mod.rs index 74ff89d4..96472626 100644 --- a/src/bot/mod.rs +++ b/src/bot/mod.rs @@ -92,7 +92,7 @@ impl Bot { where C: Into, F: Into, - M: Into, + M: Into, { ForwardMessage::new( self.ctx(), diff --git a/src/core/requests/edit_message_live_location.rs b/src/core/requests/edit_message_live_location.rs index 091b9161..3d1171d8 100644 --- a/src/core/requests/edit_message_live_location.rs +++ b/src/core/requests/edit_message_live_location.rs @@ -23,7 +23,7 @@ pub struct EditMessageLiveLocation<'a> { #[serde(skip_serializing_if = "Option::is_none")] /// Required if inline_message_id is not specified. Identifier of the /// message to edit - message_id: Option, + message_id: Option, #[serde(skip_serializing_if = "Option::is_none")] /// Required if chat_id and message_id are not specified. Identifier of /// the inline message @@ -75,7 +75,7 @@ impl<'a> EditMessageLiveLocation<'a> { self } - pub fn message_id>(mut self, message_id: T) -> Self { + pub fn message_id>(mut self, message_id: T) -> Self { self.message_id = Some(message_id.into()); self } diff --git a/src/core/requests/forward_message.rs b/src/core/requests/forward_message.rs index dc751bfd..2de100f4 100644 --- a/src/core/requests/forward_message.rs +++ b/src/core/requests/forward_message.rs @@ -24,7 +24,7 @@ pub struct ForwardMessage<'a> { /// (in the format @channelusername) pub from_chat_id: ChatId, /// Message identifier in the chat specified in from_chat_id - pub message_id: i64, + pub message_id: i32, /// Sends the message silently. Users will receive a notification with no /// sound. @@ -53,7 +53,7 @@ impl<'a> ForwardMessage<'a> { ctx: RequestContext<'a>, chat_id: ChatId, from_chat_id: ChatId, - message_id: i64, + message_id: i32, ) -> Self { Self { ctx, @@ -74,7 +74,7 @@ impl<'a> ForwardMessage<'a> { self } - pub fn message_id>(mut self, val: T) -> Self { + pub fn message_id>(mut self, val: T) -> Self { self.message_id = val.into(); self } diff --git a/src/core/requests/send_audio.rs b/src/core/requests/send_audio.rs index ab63980d..7580b7ce 100644 --- a/src/core/requests/send_audio.rs +++ b/src/core/requests/send_audio.rs @@ -55,7 +55,7 @@ pub struct SendAudio<'a> { /// sound. pub disable_notification: Option, /// If the message is a reply, ID of the original message - pub reply_to_message_id: Option, + pub reply_to_message_id: Option, pub reply_markup: Option, } @@ -174,7 +174,7 @@ impl<'a> SendAudio<'a> { self } - pub fn reply_to_message_id>( + pub fn reply_to_message_id>( mut self, reply_to_message_id: T, ) -> Self { diff --git a/src/core/requests/send_location.rs b/src/core/requests/send_location.rs index cf9770ad..9dd8af1b 100644 --- a/src/core/requests/send_location.rs +++ b/src/core/requests/send_location.rs @@ -33,7 +33,7 @@ pub struct SendLocation<'a> { disable_notification: Option, #[serde(skip_serializing_if = "Option::is_none")] /// If the message is a reply, ID of the original message - reply_to_message_id: Option, + reply_to_message_id: Option, #[serde(skip_serializing_if = "Option::is_none")] reply_markup: Option, } @@ -98,7 +98,7 @@ impl<'a> SendLocation<'a> { self } - pub fn reply_to_message_id>(mut self, val: T) -> Self { + pub fn reply_to_message_id>(mut self, val: T) -> Self { self.reply_to_message_id = Some(val.into()); self } diff --git a/src/core/requests/send_media_group.rs b/src/core/requests/send_media_group.rs index 52c41453..d95d4234 100644 --- a/src/core/requests/send_media_group.rs +++ b/src/core/requests/send_media_group.rs @@ -17,7 +17,7 @@ pub struct SendMediaGroup<'a> { pub media: Vec, pub disable_notification: Option, - pub reply_to_message_id: Option, + pub reply_to_message_id: Option, } impl<'a> Request<'a> for SendMediaGroup<'a> { @@ -96,7 +96,7 @@ impl<'a> SendMediaGroup<'a> { self } - pub fn reply_to_message_id>(mut self, val: T) -> Self { + pub fn reply_to_message_id>(mut self, val: T) -> Self { self.reply_to_message_id = Some(val.into()); self } diff --git a/src/core/requests/send_message.rs b/src/core/requests/send_message.rs index d3bf2421..ed0fcf85 100644 --- a/src/core/requests/send_message.rs +++ b/src/core/requests/send_message.rs @@ -42,7 +42,7 @@ pub struct SendMessage<'a> { pub disable_notification: Option, /// If the message is a reply, ID of the original message #[serde(skip_serializing_if = "Option::is_none")] - pub reply_to_message_id: Option, + pub reply_to_message_id: Option, #[serde(skip_serializing_if = "Option::is_none")] pub reply_markup: Option, } @@ -106,7 +106,7 @@ impl<'a> SendMessage<'a> { self } - pub fn reply_to_message_id>(mut self, val: T) -> Self { + pub fn reply_to_message_id>(mut self, val: T) -> Self { self.reply_to_message_id = Some(val.into()); self } diff --git a/src/core/requests/send_photo.rs b/src/core/requests/send_photo.rs index 9d2a07b5..69f1e5d7 100644 --- a/src/core/requests/send_photo.rs +++ b/src/core/requests/send_photo.rs @@ -39,7 +39,7 @@ pub struct SendPhoto<'a> { /// sound. pub disable_notification: Option, /// If the message is a reply, ID of the original message - pub reply_to_message_id: Option, + pub reply_to_message_id: Option, pub reply_markup: Option, } @@ -125,7 +125,7 @@ impl<'a> SendPhoto<'a> { self } - pub fn reply_to_message_id>( + pub fn reply_to_message_id>( mut self, reply_to_message_id: T, ) -> Self { diff --git a/src/core/types/contact.rs b/src/core/types/contact.rs index 83a1d81d..d5ffedca 100644 --- a/src/core/types/contact.rs +++ b/src/core/types/contact.rs @@ -8,7 +8,7 @@ pub struct Contact { /// Optional. Contact's last name pub last_name: Option, /// Optional. Contact's user identifier in Telegram - pub user_id: Option, + pub user_id: Option, /// Optional. Additional data about the contact in the form of a /// [vCard](https://en.wikipedia.org/wiki/VCard) pub vcard: Option, diff --git a/src/core/types/invoice.rs b/src/core/types/invoice.rs index 8a429e6e..201cb3fd 100644 --- a/src/core/types/invoice.rs +++ b/src/core/types/invoice.rs @@ -4,5 +4,5 @@ pub struct Invoice { pub description: String, pub start_parameter: String, pub currency: String, - pub total_amount: i64, + pub total_amount: i32, } diff --git a/src/core/types/label_price.rs b/src/core/types/label_price.rs index d7816ef3..b1d04e3d 100644 --- a/src/core/types/label_price.rs +++ b/src/core/types/label_price.rs @@ -9,7 +9,7 @@ pub struct LabeledPrice { /// amount = 145. See the exp parameter in [`currencies.json`](https://core.telegram.org/bots/payments/currencies.json), /// it shows the number of digits past the decimal point for each currency /// (2 for the majority of currencies). - pub amount: i64, + pub amount: i32, } #[cfg(test)] diff --git a/src/core/types/message.rs b/src/core/types/message.rs index a5711fc8..ebc76355 100644 --- a/src/core/types/message.rs +++ b/src/core/types/message.rs @@ -7,7 +7,7 @@ use crate::core::types::{ #[derive(Debug, Deserialize, PartialEq, Clone)] pub struct Message { #[serde(rename = "message_id")] - pub id: i64, + pub id: i32, pub date: i32, pub chat: Chat, #[serde(flatten)] @@ -91,7 +91,7 @@ pub enum ForwardKind { #[serde(rename = "forward_from_chat")] chat: Chat, #[serde(rename = "forward_from_message_id")] - message_id: i64, + message_id: i32, #[serde(rename = "forward_signature")] signature: Option, }, diff --git a/src/core/types/pre_checkout_query.rs b/src/core/types/pre_checkout_query.rs index 4a3292ba..2d136e52 100644 --- a/src/core/types/pre_checkout_query.rs +++ b/src/core/types/pre_checkout_query.rs @@ -5,7 +5,7 @@ pub struct PreCheckoutQuery { pub id: String, pub from: User, pub currency: String, - pub total_amount: i64, + pub total_amount: i32, pub invoice_payload: String, pub shipping_option_id: Option, pub order_info: Option, diff --git a/src/core/types/response_parameters.rs b/src/core/types/response_parameters.rs index c9b71243..b456d5fd 100644 --- a/src/core/types/response_parameters.rs +++ b/src/core/types/response_parameters.rs @@ -2,7 +2,7 @@ #[serde(rename_all = "snake_case")] pub enum ResponseParameters { MigrateToChatId(i64), - RetryAfter(i64), + RetryAfter(i32), } #[cfg(test)] diff --git a/src/core/types/send_invoice.rs b/src/core/types/send_invoice.rs index 07698819..10740d81 100644 --- a/src/core/types/send_invoice.rs +++ b/src/core/types/send_invoice.rs @@ -1,8 +1,9 @@ use crate::core::types::{InlineKeyboardMarkup, LabeledPrice}; +use crate::core::requests::ChatId; -#[derive(Debug, Hash, PartialEq, Eq, Clone)] +#[derive(Debug, PartialEq, Eq, Clone)] pub struct SendInvoice { - pub chat_id: i64, + pub chat_id: ChatId, pub title: String, pub description: String, pub payload: String, @@ -12,9 +13,9 @@ pub struct SendInvoice { pub prices: Vec, pub provider_data: Option, pub photo_url: Option, - pub photo_size: Option, - pub photo_width: Option, - pub photo_height: Option, + pub photo_size: Option, + pub photo_width: Option, + pub photo_height: Option, pub need_name: Option, pub need_phone_number: Option, pub need_email: Option, @@ -23,6 +24,6 @@ pub struct SendInvoice { pub send_email_to_provider: Option, pub is_flexible: Option, pub disable_notification: Option, - pub reply_to_message_id: Option, + pub reply_to_message_id: Option, pub reply_markup: Option, } diff --git a/src/core/types/successful_payment.rs b/src/core/types/successful_payment.rs index 8c39446d..c544499b 100644 --- a/src/core/types/successful_payment.rs +++ b/src/core/types/successful_payment.rs @@ -3,7 +3,7 @@ use crate::core::types::OrderInfo; #[derive(Debug, Deserialize, Hash, PartialEq, Eq, Clone, Serialize)] pub struct SuccessfulPayment { pub currency: String, - pub total_amount: i64, + pub total_amount: i32, pub invoice_payload: String, pub shipping_option_id: Option, pub order_info: Option, diff --git a/src/core/types/user.rs b/src/core/types/user.rs index 19873238..953e1a23 100644 --- a/src/core/types/user.rs +++ b/src/core/types/user.rs @@ -1,6 +1,6 @@ #[derive(Debug, Deserialize, Hash, PartialEq, Eq, Clone, Serialize)] pub struct User { - pub id: i64, + pub id: i32, pub is_bot: bool, pub first_name: String, pub last_name: Option,