From 242304b41945e6bc0f48485f0ecab94f0c661fa0 Mon Sep 17 00:00:00 2001 From: EdJoPaTo Date: Tue, 17 Sep 2024 16:54:09 +0200 Subject: [PATCH] style: group imports requires nightly for `cargo fmt` (`cargo +nightly fmt`). Without nightly it prints warnings but continues to work. --- .github/workflows/rust.yml | 32 +--- examples/api_trait_implementation.rs | 10 +- examples/async_custom_client.rs | 4 +- examples/async_file_upload.rs | 3 +- examples/async_get_me.rs | 3 +- examples/async_reply_to_message_updates.rs | 9 +- examples/custom_client.rs | 4 +- examples/get_me.rs | 3 +- examples/inline_keyboard.rs | 9 +- examples/reply_keyboard.rs | 9 +- examples/reply_to_message_updates.rs | 8 +- rustfmt.toml | 8 + src/api_params.rs | 9 +- src/client_reqwest.rs | 10 +- src/client_ureq.rs | 107 +++-------- src/error.rs | 3 +- src/objects.rs | 6 +- src/response.rs | 3 +- src/trait_async.rs | 201 +++++---------------- src/trait_sync.rs | 198 +++++--------------- 20 files changed, 188 insertions(+), 451 deletions(-) create mode 100644 rustfmt.toml diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index a337a2b..422a604 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -1,7 +1,8 @@ -name: Test and Build Rust +name: Rust on: push: + branches-ignore: ["dependabot/**"] pull_request: workflow_dispatch: schedule: @@ -12,16 +13,13 @@ jobs: rustfmt: runs-on: ubuntu-latest steps: - - name: Setup Rust - uses: dtolnay/rust-toolchain@master + - uses: dtolnay/rust-toolchain@nightly with: - toolchain: stable components: rustfmt - uses: actions/checkout@v4 - run: cargo fmt --check --verbose clippy: - name: Clippy ${{ matrix.toolchain }} runs-on: ubuntu-latest continue-on-error: ${{ (matrix.toolchain == 'beta') || (matrix.toolchain == 'nightly') }} strategy: @@ -34,9 +32,8 @@ jobs: env: RUSTFLAGS: --deny warnings steps: - - name: Setup Rust + - uses: dtolnay/rust-toolchain@master id: rust - uses: dtolnay/rust-toolchain@master with: toolchain: ${{ matrix.toolchain }} components: clippy @@ -50,7 +47,6 @@ jobs: - run: cargo doc --offline --all-features --no-deps features: - name: Features ${{ matrix.toolchain }} ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -65,16 +61,11 @@ jobs: env: RUSTFLAGS: --allow unknown-lints --deny warnings steps: - - name: Setup Rust + - uses: dtolnay/rust-toolchain@master id: rust - uses: dtolnay/rust-toolchain@master with: toolchain: ${{ matrix.toolchain }} - - - name: Install cargo-hack - uses: taiki-e/install-action@v2 - with: - tool: cargo-hack + - uses: taiki-e/install-action@cargo-hack - uses: actions/checkout@v4 - run: cargo fetch @@ -90,7 +81,6 @@ jobs: run: cargo hack --keep-going --feature-powerset --no-dev-deps check --offline test: - name: Test ${{ matrix.toolchain }} ${{ matrix.os }} runs-on: ${{ matrix.os }} continue-on-error: ${{ matrix.toolchain == 'nightly' }} strategy: @@ -105,9 +95,8 @@ jobs: - macos-latest - windows-latest steps: - - name: Setup Rust + - uses: dtolnay/rust-toolchain@master id: rust - uses: dtolnay/rust-toolchain@master with: toolchain: ${{ matrix.toolchain }} - uses: actions/checkout@v4 @@ -149,11 +138,9 @@ jobs: env: RUSTFLAGS: --deny warnings steps: - - name: Setup Rust + - uses: dtolnay/rust-toolchain@stable id: rust - uses: dtolnay/rust-toolchain@master with: - toolchain: stable targets: ${{ matrix.triple }} - name: Install cargo tools @@ -169,5 +156,4 @@ jobs: key: release-${{ matrix.triple }}-${{ steps.rust.outputs.cachekey }}-${{ hashFiles('**/Cargo.*') }} path: target/ - - name: Build - run: ${{ runner.os == 'Linux' && 'cross' || 'cargo' }} build --release --offline --all-features --target ${{ matrix.triple }} + - run: ${{ runner.os == 'Linux' && 'cross' || 'cargo' }} build --release --offline --all-features --target ${{ matrix.triple }} diff --git a/examples/api_trait_implementation.rs b/examples/api_trait_implementation.rs index 68dacb6..aa973a9 100644 --- a/examples/api_trait_implementation.rs +++ b/examples/api_trait_implementation.rs @@ -1,9 +1,11 @@ -use frankenstein::ErrorResponse; -use frankenstein::SendMessageParams; -use frankenstein::TelegramApi; -use isahc::{prelude::*, Request}; use std::path::PathBuf; +use frankenstein::api_params::SendMessageParams; +use frankenstein::response::ErrorResponse; +use frankenstein::TelegramApi; +use isahc::prelude::*; +use isahc::Request; + static TOKEN: &str = "TOKEN"; static BASE_API_URL: &str = "https://api.telegram.org/bot"; static CHAT_ID: i64 = 1; diff --git a/examples/async_custom_client.rs b/examples/async_custom_client.rs index fd1ecfc..9e9e98f 100644 --- a/examples/async_custom_client.rs +++ b/examples/async_custom_client.rs @@ -1,7 +1,7 @@ -use frankenstein::AsyncApi; -use frankenstein::AsyncTelegramApi; use std::time::Duration; +use frankenstein::{AsyncApi, AsyncTelegramApi}; + static TOKEN: &str = "API_TOKEN"; static BASE_API_URL: &str = "https://api.telegram.org/bot"; diff --git a/examples/async_file_upload.rs b/examples/async_file_upload.rs index 2d7bee9..58e6a1e 100644 --- a/examples/async_file_upload.rs +++ b/examples/async_file_upload.rs @@ -1,6 +1,5 @@ use frankenstein::api_params::SendPhotoParams; -use frankenstein::AsyncApi; -use frankenstein::AsyncTelegramApi; +use frankenstein::{AsyncApi, AsyncTelegramApi}; static TOKEN: &str = "TOKEN"; static CHAT_ID: i64 = 1; diff --git a/examples/async_get_me.rs b/examples/async_get_me.rs index 6a69d06..ef0e104 100644 --- a/examples/async_get_me.rs +++ b/examples/async_get_me.rs @@ -1,5 +1,4 @@ -use frankenstein::AsyncApi; -use frankenstein::AsyncTelegramApi; +use frankenstein::{AsyncApi, AsyncTelegramApi}; static TOKEN: &str = "API_TOKEN"; diff --git a/examples/async_reply_to_message_updates.rs b/examples/async_reply_to_message_updates.rs index 40681a2..9c8abd1 100644 --- a/examples/async_reply_to_message_updates.rs +++ b/examples/async_reply_to_message_updates.rs @@ -1,9 +1,6 @@ -use frankenstein::AsyncTelegramApi; -use frankenstein::GetUpdatesParams; -use frankenstein::Message; -use frankenstein::ReplyParameters; -use frankenstein::SendMessageParams; -use frankenstein::{AsyncApi, UpdateContent}; +use frankenstein::api_params::{GetUpdatesParams, ReplyParameters, SendMessageParams}; +use frankenstein::objects::{Message, UpdateContent}; +use frankenstein::{AsyncApi, AsyncTelegramApi}; static TOKEN: &str = "API_TOKEN"; diff --git a/examples/custom_client.rs b/examples/custom_client.rs index 4a6b462..009e91a 100644 --- a/examples/custom_client.rs +++ b/examples/custom_client.rs @@ -1,7 +1,7 @@ -use frankenstein::Api; -use frankenstein::TelegramApi; use std::time::Duration; +use frankenstein::{Api, TelegramApi}; + static TOKEN: &str = "API_TOKEN"; static BASE_API_URL: &str = "https://api.telegram.org/bot"; diff --git a/examples/get_me.rs b/examples/get_me.rs index 1ca279f..7ce6198 100644 --- a/examples/get_me.rs +++ b/examples/get_me.rs @@ -1,5 +1,4 @@ -use frankenstein::Api; -use frankenstein::TelegramApi; +use frankenstein::{Api, TelegramApi}; static TOKEN: &str = "API_TOKEN"; diff --git a/examples/inline_keyboard.rs b/examples/inline_keyboard.rs index 7dae94f..32b178d 100644 --- a/examples/inline_keyboard.rs +++ b/examples/inline_keyboard.rs @@ -1,9 +1,6 @@ -use frankenstein::Api; -use frankenstein::InlineKeyboardButton; -use frankenstein::InlineKeyboardMarkup; -use frankenstein::ReplyMarkup; -use frankenstein::SendMessageParams; -use frankenstein::TelegramApi; +use frankenstein::api_params::{ReplyMarkup, SendMessageParams}; +use frankenstein::objects::{InlineKeyboardButton, InlineKeyboardMarkup}; +use frankenstein::{Api, TelegramApi}; // replace with your token static TOKEN: &str = "TOKEN"; diff --git a/examples/reply_keyboard.rs b/examples/reply_keyboard.rs index 9780a7f..2014347 100644 --- a/examples/reply_keyboard.rs +++ b/examples/reply_keyboard.rs @@ -1,9 +1,6 @@ -use frankenstein::Api; -use frankenstein::KeyboardButton; -use frankenstein::ReplyKeyboardMarkup; -use frankenstein::ReplyMarkup; -use frankenstein::SendMessageParams; -use frankenstein::TelegramApi; +use frankenstein::api_params::{ReplyMarkup, SendMessageParams}; +use frankenstein::objects::{KeyboardButton, ReplyKeyboardMarkup}; +use frankenstein::{Api, TelegramApi}; // replace with your token static TOKEN: &str = "TOKEN"; diff --git a/examples/reply_to_message_updates.rs b/examples/reply_to_message_updates.rs index 8531c34..dcbf262 100644 --- a/examples/reply_to_message_updates.rs +++ b/examples/reply_to_message_updates.rs @@ -1,8 +1,6 @@ -use frankenstein::GetUpdatesParams; -use frankenstein::ReplyParameters; -use frankenstein::SendMessageParams; -use frankenstein::TelegramApi; -use frankenstein::{Api, UpdateContent}; +use frankenstein::api_params::{GetUpdatesParams, ReplyParameters, SendMessageParams}; +use frankenstein::objects::UpdateContent; +use frankenstein::{Api, TelegramApi}; static TOKEN: &str = "API_TOKEN"; diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 0000000..d3f9cda --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1,8 @@ +# https://github.com/rust-lang/rustfmt/blob/master/Configurations.md +format_code_in_doc_comments=true +format_macro_matchers=true +group_imports="StdExternalCrate" +imports_granularity="Module" +normalize_doc_attributes=true +reorder_impl_items=true +use_field_init_shorthand=true diff --git a/src/api_params.rs b/src/api_params.rs index 64a5c7d..315806f 100644 --- a/src/api_params.rs +++ b/src/api_params.rs @@ -1,5 +1,10 @@ //! Parameters to Telegram API methods. +use std::path::PathBuf; + +use bon::Builder; +use serde::{Deserialize, Serialize}; + use crate::objects::{ AllowedUpdate, BotCommand, ChatAdministratorRights, ChatPermissions, ForceReply, InlineKeyboardMarkup, InlineQueryResultArticle, InlineQueryResultAudio, @@ -18,10 +23,6 @@ use crate::objects::{ WebAppInfo, }; use crate::ParseMode; -use bon::Builder; -use serde::Deserialize; -use serde::Serialize; -use std::path::PathBuf; #[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)] #[serde(untagged)] diff --git a/src/client_reqwest.rs b/src/client_reqwest.rs index c8a892c..8523dd2 100644 --- a/src/client_reqwest.rs +++ b/src/client_reqwest.rs @@ -1,13 +1,15 @@ -use crate::trait_async::AsyncTelegramApi; -use crate::Error; +use std::path::PathBuf; +use std::time::Duration; + use async_trait::async_trait; use bon::Builder; use reqwest::multipart; use serde_json::Value; -use std::path::PathBuf; -use std::time::Duration; use tokio::fs::File; +use crate::trait_async::AsyncTelegramApi; +use crate::Error; + /// Asynchronous [`AsyncTelegramApi`] client implementation with [`reqwest`]. #[derive(Debug, Clone, Builder)] #[must_use = "API needs to be used in order to be useful"] diff --git a/src/client_ureq.rs b/src/client_ureq.rs index 8dbc4b5..acbc085 100644 --- a/src/client_ureq.rs +++ b/src/client_ureq.rs @@ -1,12 +1,14 @@ -use crate::trait_sync::TelegramApi; -use crate::Error; +use std::path::PathBuf; +use std::time::Duration; + use bon::Builder; use multipart::client::lazy::Multipart; use serde_json::Value; -use std::path::PathBuf; -use std::time::Duration; use ureq::Response; +use crate::trait_sync::TelegramApi; +use crate::Error; + /// Synchronous [`TelegramApi`] client implementation with [`ureq`]. #[derive(Debug, Clone, Builder)] #[must_use = "API needs to be used in order to be useful"] @@ -142,80 +144,29 @@ impl TelegramApi for Api { #[cfg(test)] mod tests { use super::*; - use crate::api_params::AnswerCallbackQueryParams; - use crate::api_params::AnswerInlineQueryParams; - use crate::api_params::BanChatMemberParams; - use crate::api_params::BotCommandScope; - use crate::api_params::BotCommandScopeChat; - use crate::api_params::ChatAction; - use crate::api_params::ChatId; - use crate::api_params::CopyMessageParams; - use crate::api_params::CreateChatInviteLinkParams; - use crate::api_params::DeleteChatPhotoParams; - use crate::api_params::DeleteChatStickerSetParams; - use crate::api_params::DeleteMessageParams; - use crate::api_params::DeleteMyCommandsParams; - use crate::api_params::DeleteWebhookParams; - use crate::api_params::EditChatInviteLinkParams; - use crate::api_params::EditMessageCaptionParams; - use crate::api_params::EditMessageLiveLocationParams; - use crate::api_params::EditMessageMediaParams; - use crate::api_params::EditMessageTextParams; - use crate::api_params::ExportChatInviteLinkParams; - use crate::api_params::FileUpload; - use crate::api_params::ForwardMessageParams; - use crate::api_params::GetChatAdministratorsParams; - use crate::api_params::GetChatMemberCountParams; - use crate::api_params::GetChatMemberParams; - use crate::api_params::GetChatParams; - use crate::api_params::GetFileParams; - use crate::api_params::GetMyCommandsParams; - use crate::api_params::GetStickerSetParams; - use crate::api_params::GetUpdatesParams; - use crate::api_params::GetUserProfilePhotosParams; - use crate::api_params::InlineQueryResult; - use crate::api_params::InputFile; - use crate::api_params::InputMedia; - use crate::api_params::InputMediaPhoto; - use crate::api_params::LeaveChatParams; - use crate::api_params::Media; - use crate::api_params::PinChatMessageParams; - use crate::api_params::PromoteChatMemberParams; - use crate::api_params::RestrictChatMemberParams; - use crate::api_params::RevokeChatInviteLinkParams; - use crate::api_params::SendAnimationParams; - use crate::api_params::SendAudioParams; - use crate::api_params::SendChatActionParams; - use crate::api_params::SendContactParams; - use crate::api_params::SendDiceParams; - use crate::api_params::SendDocumentParams; - use crate::api_params::SendLocationParams; - use crate::api_params::SendMediaGroupParams; - use crate::api_params::SendMessageParams; - use crate::api_params::SendPhotoParams; - use crate::api_params::SendPollParams; - use crate::api_params::SendStickerParams; - use crate::api_params::SendVenueParams; - use crate::api_params::SendVideoNoteParams; - use crate::api_params::SendVideoParams; - use crate::api_params::SendVoiceParams; - use crate::api_params::SetChatAdministratorCustomTitleParams; - use crate::api_params::SetChatDescriptionParams; - use crate::api_params::SetChatPermissionsParams; - use crate::api_params::SetChatPhotoParams; - use crate::api_params::SetChatStickerSetParams; - use crate::api_params::SetChatTitleParams; - use crate::api_params::SetMyCommandsParams; - use crate::api_params::SetWebhookParams; - use crate::api_params::StopMessageLiveLocationParams; - use crate::api_params::StopPollParams; - use crate::api_params::UnbanChatMemberParams; - use crate::api_params::UnpinChatMessageParams; - use crate::objects::AllowedUpdate; - use crate::objects::BotCommand; - use crate::objects::ChatPermissions; - use crate::objects::InlineQueryResultVenue; - use crate::objects::InputPollOption; + use crate::api_params::{ + AnswerCallbackQueryParams, AnswerInlineQueryParams, BanChatMemberParams, BotCommandScope, + BotCommandScopeChat, ChatAction, ChatId, CopyMessageParams, CreateChatInviteLinkParams, + DeleteChatPhotoParams, DeleteChatStickerSetParams, DeleteMessageParams, + DeleteMyCommandsParams, DeleteWebhookParams, EditChatInviteLinkParams, + EditMessageCaptionParams, EditMessageLiveLocationParams, EditMessageMediaParams, + EditMessageTextParams, ExportChatInviteLinkParams, FileUpload, ForwardMessageParams, + GetChatAdministratorsParams, GetChatMemberCountParams, GetChatMemberParams, GetChatParams, + GetFileParams, GetMyCommandsParams, GetStickerSetParams, GetUpdatesParams, + GetUserProfilePhotosParams, InlineQueryResult, InputFile, InputMedia, InputMediaPhoto, + LeaveChatParams, Media, PinChatMessageParams, PromoteChatMemberParams, + RestrictChatMemberParams, RevokeChatInviteLinkParams, SendAnimationParams, SendAudioParams, + SendChatActionParams, SendContactParams, SendDiceParams, SendDocumentParams, + SendLocationParams, SendMediaGroupParams, SendMessageParams, SendPhotoParams, + SendPollParams, SendStickerParams, SendVenueParams, SendVideoNoteParams, SendVideoParams, + SendVoiceParams, SetChatAdministratorCustomTitleParams, SetChatDescriptionParams, + SetChatPermissionsParams, SetChatPhotoParams, SetChatStickerSetParams, SetChatTitleParams, + SetMyCommandsParams, SetWebhookParams, StopMessageLiveLocationParams, StopPollParams, + UnbanChatMemberParams, UnpinChatMessageParams, + }; + use crate::objects::{ + AllowedUpdate, BotCommand, ChatPermissions, InlineQueryResultVenue, InputPollOption, + }; use crate::response::ErrorResponse; #[test] diff --git a/src/error.rs b/src/error.rs index 02e6b16..da9a336 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,6 +1,7 @@ -use crate::response::ErrorResponse; use serde::{Deserialize, Serialize}; +use crate::response::ErrorResponse; + #[derive(Debug, Serialize, Deserialize, PartialEq, Eq, thiserror::Error)] #[non_exhaustive] #[serde(untagged)] diff --git a/src/objects.rs b/src/objects.rs index e971da4..8112a99 100644 --- a/src/objects.rs +++ b/src/objects.rs @@ -1,11 +1,13 @@ //! Objects returned or used with the Telegram API. #![allow(deprecated)] -use crate::api_params::FileUpload; -use crate::ParseMode; + use bon::Builder; use serde::{Deserialize, Serialize}; +use crate::api_params::FileUpload; +use crate::ParseMode; + #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] #[serde(rename_all = "snake_case")] pub enum StickerType { diff --git a/src/response.rs b/src/response.rs index f2b2a4e..0efa806 100644 --- a/src/response.rs +++ b/src/response.rs @@ -4,9 +4,10 @@ #![allow(clippy::module_name_repetitions)] -use crate::objects::{Message, ResponseParameters}; use serde::{Deserialize, Serialize}; +use crate::objects::{Message, ResponseParameters}; + #[derive(Debug, Serialize, Deserialize, PartialEq, Eq)] pub struct MethodResponse { /// Always true diff --git a/src/trait_async.rs b/src/trait_async.rs index 1b146d5..968952d 100644 --- a/src/trait_async.rs +++ b/src/trait_async.rs @@ -1,156 +1,55 @@ -use crate::api_params::AddStickerToSetParams; -use crate::api_params::AnswerCallbackQueryParams; -use crate::api_params::AnswerInlineQueryParams; -use crate::api_params::AnswerPreCheckoutQueryParams; -use crate::api_params::AnswerShippingQueryParams; -use crate::api_params::AnswerWebAppQueryParams; -use crate::api_params::ApproveChatJoinRequestParams; -use crate::api_params::BanChatMemberParams; -use crate::api_params::BanChatSenderChatParams; -use crate::api_params::CloseForumTopicParams; -use crate::api_params::CloseGeneralForumTopicParams; -use crate::api_params::CopyMessageParams; -use crate::api_params::CopyMessagesParams; -use crate::api_params::CreateChatInviteLinkParams; -use crate::api_params::CreateChatSubscriptionInviteLinkParams; -use crate::api_params::CreateForumTopicParams; -use crate::api_params::CreateInvoiceLinkParams; -use crate::api_params::CreateNewStickerSetParams; -use crate::api_params::DeclineChatJoinRequestParams; -use crate::api_params::DeleteChatPhotoParams; -use crate::api_params::DeleteChatStickerSetParams; -use crate::api_params::DeleteForumTopicParams; -use crate::api_params::DeleteMessageParams; -use crate::api_params::DeleteMessagesParams; -use crate::api_params::DeleteMyCommandsParams; -use crate::api_params::DeleteStickerFromSetParams; -use crate::api_params::DeleteStickerSetParams; -use crate::api_params::DeleteWebhookParams; -use crate::api_params::EditChatInviteLinkParams; -use crate::api_params::EditChatSubscriptionInviteLinkParams; -use crate::api_params::EditForumTopicParams; -use crate::api_params::EditGeneralForumTopicParams; -use crate::api_params::EditMessageCaptionParams; -use crate::api_params::EditMessageLiveLocationParams; -use crate::api_params::EditMessageMediaParams; -use crate::api_params::EditMessageReplyMarkupParams; -use crate::api_params::EditMessageTextParams; -use crate::api_params::ExportChatInviteLinkParams; -use crate::api_params::FileUpload; -use crate::api_params::ForwardMessageParams; -use crate::api_params::ForwardMessagesParams; -use crate::api_params::GetBusinessConnectionParams; -use crate::api_params::GetChatAdministratorsParams; -use crate::api_params::GetChatMemberCountParams; -use crate::api_params::GetChatMemberParams; -use crate::api_params::GetChatMenuButtonParams; -use crate::api_params::GetChatParams; -use crate::api_params::GetCustomEmojiStickersParams; -use crate::api_params::GetFileParams; -use crate::api_params::GetGameHighScoresParams; -use crate::api_params::GetMyCommandsParams; -use crate::api_params::GetMyDefaultAdministratorRightsParams; -use crate::api_params::GetMyDescriptionParams; -use crate::api_params::GetMyNameParams; -use crate::api_params::GetMyShortDescriptionParams; -use crate::api_params::GetStarTransactionsParams; -use crate::api_params::GetStickerSetParams; -use crate::api_params::GetUpdatesParams; -use crate::api_params::GetUserChatBoostsParams; -use crate::api_params::GetUserProfilePhotosParams; -use crate::api_params::HideGeneralForumTopicParams; -use crate::api_params::InputMedia; -use crate::api_params::LeaveChatParams; -use crate::api_params::Media; -use crate::api_params::PinChatMessageParams; -use crate::api_params::PromoteChatMemberParams; -use crate::api_params::RefundStarPaymentParams; -use crate::api_params::ReopenForumTopicParams; -use crate::api_params::ReopenGeneralForumTopicParams; -use crate::api_params::ReplaceStickerInSetParams; -use crate::api_params::RestrictChatMemberParams; -use crate::api_params::RevokeChatInviteLinkParams; -use crate::api_params::SendAnimationParams; -use crate::api_params::SendAudioParams; -use crate::api_params::SendChatActionParams; -use crate::api_params::SendContactParams; -use crate::api_params::SendDiceParams; -use crate::api_params::SendDocumentParams; -use crate::api_params::SendGameParams; -use crate::api_params::SendInvoiceParams; -use crate::api_params::SendLocationParams; -use crate::api_params::SendMediaGroupParams; -use crate::api_params::SendMessageParams; -use crate::api_params::SendPaidMediaParams; -use crate::api_params::SendPhotoParams; -use crate::api_params::SendPollParams; -use crate::api_params::SendStickerParams; -use crate::api_params::SendVenueParams; -use crate::api_params::SendVideoNoteParams; -use crate::api_params::SendVideoParams; -use crate::api_params::SendVoiceParams; -use crate::api_params::SetChatAdministratorCustomTitleParams; -use crate::api_params::SetChatDescriptionParams; -use crate::api_params::SetChatMenuButtonParams; -use crate::api_params::SetChatPermissionsParams; -use crate::api_params::SetChatPhotoParams; -use crate::api_params::SetChatStickerSetParams; -use crate::api_params::SetChatTitleParams; -use crate::api_params::SetCustomEmojiStickerSetThumbnailParams; -use crate::api_params::SetGameScoreParams; -use crate::api_params::SetMessageReactionParams; -use crate::api_params::SetMyCommandsParams; -use crate::api_params::SetMyDefaultAdministratorRightsParams; -use crate::api_params::SetMyDescriptionParams; -use crate::api_params::SetMyNameParams; -use crate::api_params::SetMyShortDescriptionParams; -use crate::api_params::SetStickerEmojiListParams; -use crate::api_params::SetStickerKeywordsParams; -use crate::api_params::SetStickerMaskPositionParams; -use crate::api_params::SetStickerPositionInSetParams; -use crate::api_params::SetStickerSetThumbnailParams; -use crate::api_params::SetStickerSetTitleParams; -use crate::api_params::SetWebhookParams; -use crate::api_params::StopMessageLiveLocationParams; -use crate::api_params::StopPollParams; -use crate::api_params::UnbanChatMemberParams; -use crate::api_params::UnbanChatSenderChatParams; -use crate::api_params::UnhideGeneralForumTopicParams; -use crate::api_params::UnpinAllChatMessagesParams; -use crate::api_params::UnpinAllForumTopicMessagesParams; -use crate::api_params::UnpinAllGeneralForumTopicMessagesParams; -use crate::api_params::UnpinChatMessageParams; -use crate::api_params::UploadStickerFileParams; -use crate::objects::BotCommand; -use crate::objects::BotDescription; -use crate::objects::BotName; -use crate::objects::BotShortDescription; -use crate::objects::BusinessConnection; -use crate::objects::ChatAdministratorRights; -use crate::objects::ChatFullInfo; -use crate::objects::ChatInviteLink; -use crate::objects::ChatMember; -use crate::objects::File as FileObject; -use crate::objects::ForumTopic; -use crate::objects::GameHighScore; -use crate::objects::InputSticker; -use crate::objects::MenuButton; -use crate::objects::Message; -use crate::objects::MessageId; -use crate::objects::Poll; -use crate::objects::SentWebAppMessage; -use crate::objects::StarTransactions; -use crate::objects::Sticker; -use crate::objects::StickerSet; -use crate::objects::Update; -use crate::objects::User; -use crate::objects::UserChatBoosts; -use crate::objects::UserProfilePhotos; -use crate::objects::WebhookInfo; -use crate::response::{MessageOrBool, MethodResponse}; -use async_trait::async_trait; use std::path::PathBuf; +use async_trait::async_trait; + +use crate::api_params::{ + AddStickerToSetParams, AnswerCallbackQueryParams, AnswerInlineQueryParams, + AnswerPreCheckoutQueryParams, AnswerShippingQueryParams, AnswerWebAppQueryParams, + ApproveChatJoinRequestParams, BanChatMemberParams, BanChatSenderChatParams, + CloseForumTopicParams, CloseGeneralForumTopicParams, CopyMessageParams, CopyMessagesParams, + CreateChatInviteLinkParams, CreateChatSubscriptionInviteLinkParams, CreateForumTopicParams, + CreateInvoiceLinkParams, CreateNewStickerSetParams, DeclineChatJoinRequestParams, + DeleteChatPhotoParams, DeleteChatStickerSetParams, DeleteForumTopicParams, DeleteMessageParams, + DeleteMessagesParams, DeleteMyCommandsParams, DeleteStickerFromSetParams, + DeleteStickerSetParams, DeleteWebhookParams, EditChatInviteLinkParams, + EditChatSubscriptionInviteLinkParams, EditForumTopicParams, EditGeneralForumTopicParams, + EditMessageCaptionParams, EditMessageLiveLocationParams, EditMessageMediaParams, + EditMessageReplyMarkupParams, EditMessageTextParams, ExportChatInviteLinkParams, FileUpload, + ForwardMessageParams, ForwardMessagesParams, GetBusinessConnectionParams, + GetChatAdministratorsParams, GetChatMemberCountParams, GetChatMemberParams, + GetChatMenuButtonParams, GetChatParams, GetCustomEmojiStickersParams, GetFileParams, + GetGameHighScoresParams, GetMyCommandsParams, GetMyDefaultAdministratorRightsParams, + GetMyDescriptionParams, GetMyNameParams, GetMyShortDescriptionParams, + GetStarTransactionsParams, GetStickerSetParams, GetUpdatesParams, GetUserChatBoostsParams, + GetUserProfilePhotosParams, HideGeneralForumTopicParams, InputMedia, LeaveChatParams, Media, + PinChatMessageParams, PromoteChatMemberParams, RefundStarPaymentParams, ReopenForumTopicParams, + ReopenGeneralForumTopicParams, ReplaceStickerInSetParams, RestrictChatMemberParams, + RevokeChatInviteLinkParams, SendAnimationParams, SendAudioParams, SendChatActionParams, + SendContactParams, SendDiceParams, SendDocumentParams, SendGameParams, SendInvoiceParams, + SendLocationParams, SendMediaGroupParams, SendMessageParams, SendPaidMediaParams, + SendPhotoParams, SendPollParams, SendStickerParams, SendVenueParams, SendVideoNoteParams, + SendVideoParams, SendVoiceParams, SetChatAdministratorCustomTitleParams, + SetChatDescriptionParams, SetChatMenuButtonParams, SetChatPermissionsParams, + SetChatPhotoParams, SetChatStickerSetParams, SetChatTitleParams, + SetCustomEmojiStickerSetThumbnailParams, SetGameScoreParams, SetMessageReactionParams, + SetMyCommandsParams, SetMyDefaultAdministratorRightsParams, SetMyDescriptionParams, + SetMyNameParams, SetMyShortDescriptionParams, SetStickerEmojiListParams, + SetStickerKeywordsParams, SetStickerMaskPositionParams, SetStickerPositionInSetParams, + SetStickerSetThumbnailParams, SetStickerSetTitleParams, SetWebhookParams, + StopMessageLiveLocationParams, StopPollParams, UnbanChatMemberParams, + UnbanChatSenderChatParams, UnhideGeneralForumTopicParams, UnpinAllChatMessagesParams, + UnpinAllForumTopicMessagesParams, UnpinAllGeneralForumTopicMessagesParams, + UnpinChatMessageParams, UploadStickerFileParams, +}; +use crate::objects::{ + BotCommand, BotDescription, BotName, BotShortDescription, BusinessConnection, + ChatAdministratorRights, ChatFullInfo, ChatInviteLink, ChatMember, File as FileObject, + ForumTopic, GameHighScore, InputSticker, MenuButton, Message, MessageId, Poll, + SentWebAppMessage, StarTransactions, Sticker, StickerSet, Update, User, UserChatBoosts, + UserProfilePhotos, WebhookInfo, +}; +use crate::response::{MessageOrBool, MethodResponse}; + #[async_trait] pub trait AsyncTelegramApi { type Error; diff --git a/src/trait_sync.rs b/src/trait_sync.rs index 9bc9545..a4317d2 100644 --- a/src/trait_sync.rs +++ b/src/trait_sync.rs @@ -1,155 +1,53 @@ -use crate::api_params::AddStickerToSetParams; -use crate::api_params::AnswerCallbackQueryParams; -use crate::api_params::AnswerInlineQueryParams; -use crate::api_params::AnswerPreCheckoutQueryParams; -use crate::api_params::AnswerShippingQueryParams; -use crate::api_params::AnswerWebAppQueryParams; -use crate::api_params::ApproveChatJoinRequestParams; -use crate::api_params::BanChatMemberParams; -use crate::api_params::BanChatSenderChatParams; -use crate::api_params::CloseForumTopicParams; -use crate::api_params::CloseGeneralForumTopicParams; -use crate::api_params::CopyMessageParams; -use crate::api_params::CopyMessagesParams; -use crate::api_params::CreateChatInviteLinkParams; -use crate::api_params::CreateChatSubscriptionInviteLinkParams; -use crate::api_params::CreateForumTopicParams; -use crate::api_params::CreateInvoiceLinkParams; -use crate::api_params::CreateNewStickerSetParams; -use crate::api_params::DeclineChatJoinRequestParams; -use crate::api_params::DeleteChatPhotoParams; -use crate::api_params::DeleteChatStickerSetParams; -use crate::api_params::DeleteForumTopicParams; -use crate::api_params::DeleteMessageParams; -use crate::api_params::DeleteMessagesParams; -use crate::api_params::DeleteMyCommandsParams; -use crate::api_params::DeleteStickerFromSetParams; -use crate::api_params::DeleteStickerSetParams; -use crate::api_params::DeleteWebhookParams; -use crate::api_params::EditChatInviteLinkParams; -use crate::api_params::EditChatSubscriptionInviteLinkParams; -use crate::api_params::EditForumTopicParams; -use crate::api_params::EditGeneralForumTopicParams; -use crate::api_params::EditMessageCaptionParams; -use crate::api_params::EditMessageLiveLocationParams; -use crate::api_params::EditMessageMediaParams; -use crate::api_params::EditMessageReplyMarkupParams; -use crate::api_params::EditMessageTextParams; -use crate::api_params::ExportChatInviteLinkParams; -use crate::api_params::FileUpload; -use crate::api_params::ForwardMessageParams; -use crate::api_params::ForwardMessagesParams; -use crate::api_params::GetBusinessConnectionParams; -use crate::api_params::GetChatAdministratorsParams; -use crate::api_params::GetChatMemberCountParams; -use crate::api_params::GetChatMemberParams; -use crate::api_params::GetChatMenuButtonParams; -use crate::api_params::GetChatParams; -use crate::api_params::GetCustomEmojiStickersParams; -use crate::api_params::GetFileParams; -use crate::api_params::GetGameHighScoresParams; -use crate::api_params::GetMyCommandsParams; -use crate::api_params::GetMyDefaultAdministratorRightsParams; -use crate::api_params::GetMyDescriptionParams; -use crate::api_params::GetMyNameParams; -use crate::api_params::GetMyShortDescriptionParams; -use crate::api_params::GetStarTransactionsParams; -use crate::api_params::GetStickerSetParams; -use crate::api_params::GetUpdatesParams; -use crate::api_params::GetUserChatBoostsParams; -use crate::api_params::GetUserProfilePhotosParams; -use crate::api_params::HideGeneralForumTopicParams; -use crate::api_params::InputMedia; -use crate::api_params::LeaveChatParams; -use crate::api_params::Media; -use crate::api_params::PinChatMessageParams; -use crate::api_params::PromoteChatMemberParams; -use crate::api_params::RefundStarPaymentParams; -use crate::api_params::ReopenForumTopicParams; -use crate::api_params::ReopenGeneralForumTopicParams; -use crate::api_params::ReplaceStickerInSetParams; -use crate::api_params::RestrictChatMemberParams; -use crate::api_params::RevokeChatInviteLinkParams; -use crate::api_params::SendAnimationParams; -use crate::api_params::SendAudioParams; -use crate::api_params::SendChatActionParams; -use crate::api_params::SendContactParams; -use crate::api_params::SendDiceParams; -use crate::api_params::SendDocumentParams; -use crate::api_params::SendGameParams; -use crate::api_params::SendInvoiceParams; -use crate::api_params::SendLocationParams; -use crate::api_params::SendMediaGroupParams; -use crate::api_params::SendMessageParams; -use crate::api_params::SendPaidMediaParams; -use crate::api_params::SendPhotoParams; -use crate::api_params::SendPollParams; -use crate::api_params::SendStickerParams; -use crate::api_params::SendVenueParams; -use crate::api_params::SendVideoNoteParams; -use crate::api_params::SendVideoParams; -use crate::api_params::SendVoiceParams; -use crate::api_params::SetChatAdministratorCustomTitleParams; -use crate::api_params::SetChatDescriptionParams; -use crate::api_params::SetChatMenuButtonParams; -use crate::api_params::SetChatPermissionsParams; -use crate::api_params::SetChatPhotoParams; -use crate::api_params::SetChatStickerSetParams; -use crate::api_params::SetChatTitleParams; -use crate::api_params::SetCustomEmojiStickerSetThumbnailParams; -use crate::api_params::SetGameScoreParams; -use crate::api_params::SetMessageReactionParams; -use crate::api_params::SetMyCommandsParams; -use crate::api_params::SetMyDefaultAdministratorRightsParams; -use crate::api_params::SetMyDescriptionParams; -use crate::api_params::SetMyNameParams; -use crate::api_params::SetMyShortDescriptionParams; -use crate::api_params::SetStickerEmojiListParams; -use crate::api_params::SetStickerKeywordsParams; -use crate::api_params::SetStickerMaskPositionParams; -use crate::api_params::SetStickerPositionInSetParams; -use crate::api_params::SetStickerSetThumbnailParams; -use crate::api_params::SetStickerSetTitleParams; -use crate::api_params::SetWebhookParams; -use crate::api_params::StopMessageLiveLocationParams; -use crate::api_params::StopPollParams; -use crate::api_params::UnbanChatMemberParams; -use crate::api_params::UnbanChatSenderChatParams; -use crate::api_params::UnhideGeneralForumTopicParams; -use crate::api_params::UnpinAllChatMessagesParams; -use crate::api_params::UnpinAllForumTopicMessagesParams; -use crate::api_params::UnpinAllGeneralForumTopicMessagesParams; -use crate::api_params::UnpinChatMessageParams; -use crate::api_params::UploadStickerFileParams; -use crate::objects::BotCommand; -use crate::objects::BotDescription; -use crate::objects::BotName; -use crate::objects::BotShortDescription; -use crate::objects::BusinessConnection; -use crate::objects::ChatAdministratorRights; -use crate::objects::ChatFullInfo; -use crate::objects::ChatInviteLink; -use crate::objects::ChatMember; -use crate::objects::File as FileObject; -use crate::objects::ForumTopic; -use crate::objects::GameHighScore; -use crate::objects::InputSticker; -use crate::objects::MenuButton; -use crate::objects::Message; -use crate::objects::MessageId; -use crate::objects::Poll; -use crate::objects::SentWebAppMessage; -use crate::objects::StarTransactions; -use crate::objects::Sticker; -use crate::objects::StickerSet; -use crate::objects::Update; -use crate::objects::User; -use crate::objects::UserChatBoosts; -use crate::objects::UserProfilePhotos; -use crate::objects::WebhookInfo; -use crate::response::{MessageOrBool, MethodResponse}; use std::path::PathBuf; +use crate::api_params::{ + AddStickerToSetParams, AnswerCallbackQueryParams, AnswerInlineQueryParams, + AnswerPreCheckoutQueryParams, AnswerShippingQueryParams, AnswerWebAppQueryParams, + ApproveChatJoinRequestParams, BanChatMemberParams, BanChatSenderChatParams, + CloseForumTopicParams, CloseGeneralForumTopicParams, CopyMessageParams, CopyMessagesParams, + CreateChatInviteLinkParams, CreateChatSubscriptionInviteLinkParams, CreateForumTopicParams, + CreateInvoiceLinkParams, CreateNewStickerSetParams, DeclineChatJoinRequestParams, + DeleteChatPhotoParams, DeleteChatStickerSetParams, DeleteForumTopicParams, DeleteMessageParams, + DeleteMessagesParams, DeleteMyCommandsParams, DeleteStickerFromSetParams, + DeleteStickerSetParams, DeleteWebhookParams, EditChatInviteLinkParams, + EditChatSubscriptionInviteLinkParams, EditForumTopicParams, EditGeneralForumTopicParams, + EditMessageCaptionParams, EditMessageLiveLocationParams, EditMessageMediaParams, + EditMessageReplyMarkupParams, EditMessageTextParams, ExportChatInviteLinkParams, FileUpload, + ForwardMessageParams, ForwardMessagesParams, GetBusinessConnectionParams, + GetChatAdministratorsParams, GetChatMemberCountParams, GetChatMemberParams, + GetChatMenuButtonParams, GetChatParams, GetCustomEmojiStickersParams, GetFileParams, + GetGameHighScoresParams, GetMyCommandsParams, GetMyDefaultAdministratorRightsParams, + GetMyDescriptionParams, GetMyNameParams, GetMyShortDescriptionParams, + GetStarTransactionsParams, GetStickerSetParams, GetUpdatesParams, GetUserChatBoostsParams, + GetUserProfilePhotosParams, HideGeneralForumTopicParams, InputMedia, LeaveChatParams, Media, + PinChatMessageParams, PromoteChatMemberParams, RefundStarPaymentParams, ReopenForumTopicParams, + ReopenGeneralForumTopicParams, ReplaceStickerInSetParams, RestrictChatMemberParams, + RevokeChatInviteLinkParams, SendAnimationParams, SendAudioParams, SendChatActionParams, + SendContactParams, SendDiceParams, SendDocumentParams, SendGameParams, SendInvoiceParams, + SendLocationParams, SendMediaGroupParams, SendMessageParams, SendPaidMediaParams, + SendPhotoParams, SendPollParams, SendStickerParams, SendVenueParams, SendVideoNoteParams, + SendVideoParams, SendVoiceParams, SetChatAdministratorCustomTitleParams, + SetChatDescriptionParams, SetChatMenuButtonParams, SetChatPermissionsParams, + SetChatPhotoParams, SetChatStickerSetParams, SetChatTitleParams, + SetCustomEmojiStickerSetThumbnailParams, SetGameScoreParams, SetMessageReactionParams, + SetMyCommandsParams, SetMyDefaultAdministratorRightsParams, SetMyDescriptionParams, + SetMyNameParams, SetMyShortDescriptionParams, SetStickerEmojiListParams, + SetStickerKeywordsParams, SetStickerMaskPositionParams, SetStickerPositionInSetParams, + SetStickerSetThumbnailParams, SetStickerSetTitleParams, SetWebhookParams, + StopMessageLiveLocationParams, StopPollParams, UnbanChatMemberParams, + UnbanChatSenderChatParams, UnhideGeneralForumTopicParams, UnpinAllChatMessagesParams, + UnpinAllForumTopicMessagesParams, UnpinAllGeneralForumTopicMessagesParams, + UnpinChatMessageParams, UploadStickerFileParams, +}; +use crate::objects::{ + BotCommand, BotDescription, BotName, BotShortDescription, BusinessConnection, + ChatAdministratorRights, ChatFullInfo, ChatInviteLink, ChatMember, File as FileObject, + ForumTopic, GameHighScore, InputSticker, MenuButton, Message, MessageId, Poll, + SentWebAppMessage, StarTransactions, Sticker, StickerSet, Update, User, UserChatBoosts, + UserProfilePhotos, WebhookInfo, +}; +use crate::response::{MessageOrBool, MethodResponse}; + pub trait TelegramApi { type Error;