From 25b02ba99a8f8c704f3872eeb9e952985425d0c9 Mon Sep 17 00:00:00 2001 From: StNicolay Date: Mon, 13 May 2024 13:58:56 +0300 Subject: [PATCH] Removed inlines --- src/callbacks/alter.rs | 3 --- src/callbacks/change_locale.rs | 1 - src/callbacks/decrypt.rs | 2 -- src/callbacks/delete.rs | 2 -- src/callbacks/delete_message.rs | 1 - src/callbacks/get.rs | 1 - src/callbacks/get_menu.rs | 1 - src/commands/add_account.rs | 1 - src/commands/cancel.rs | 1 - src/commands/change_language.rs | 1 - src/commands/delete.rs | 1 - src/commands/delete_all.rs | 1 - src/commands/export.rs | 2 -- src/commands/gen_password.rs | 1 - src/commands/get_account.rs | 1 - src/commands/get_accounts.rs | 1 - src/commands/help.rs | 1 - src/commands/import.rs | 2 -- src/commands/menu.rs | 1 - src/commands/set_master_pass.rs | 3 --- src/commands/start.rs | 1 - src/cryptography.rs | 1 - src/cryptography/account.rs | 6 ------ src/cryptography/hashing.rs | 4 ---- src/cryptography/passwords.rs | 4 ---- src/dispatching/default.rs | 1 - src/dispatching/delete_mesage_handler.rs | 1 - src/dispatching/filter_user_info.rs | 3 --- src/dispatching/master_password_check.rs | 3 --- src/entity/account.rs | 16 ---------------- src/entity/master_pass.rs | 3 --- src/errors.rs | 3 --- src/macros.rs | 3 --- src/markups.rs | 6 ------ src/state/generic.rs | 1 - src/state/get_login.rs | 1 - src/state/get_master_pass.rs | 1 - src/state/get_new_master_pass.rs | 2 -- src/state/get_new_name.rs | 1 - src/state/get_password.rs | 1 - src/state/get_user.rs | 6 ------ src/state/handler.rs | 4 ---- 42 files changed, 100 deletions(-) diff --git a/src/callbacks/alter.rs b/src/callbacks/alter.rs index bb034ef..7e94aa0 100644 --- a/src/callbacks/alter.rs +++ b/src/callbacks/alter.rs @@ -2,7 +2,6 @@ use super::AlterableField::{self, Login, Name, Pass}; use crate::{change_state, cryptography::account::Cipher, prelude::*}; use tokio::task::spawn_blocking; -#[inline] async fn update_account( user_id: u64, db: &Pool, @@ -38,7 +37,6 @@ async fn update_account( Ok(updated) } -#[inline] #[allow(clippy::too_many_arguments)] async fn get_master_pass( bot: Throttle, @@ -72,7 +70,6 @@ async fn get_master_pass( handler!(get_field(name:String, field:AlterableField, field_value:String),send_master_password, State::GetMasterPass, get_master_pass); -#[inline] pub async fn alter( bot: Throttle, q: CallbackQuery, diff --git a/src/callbacks/change_locale.rs b/src/callbacks/change_locale.rs index 45399c4..3e0be8a 100644 --- a/src/callbacks/change_locale.rs +++ b/src/callbacks/change_locale.rs @@ -2,7 +2,6 @@ use crate::{ entity::locale::LocaleType, locales::LocaleTypeExt, markups::language_markup, prelude::*, }; -#[inline] pub async fn change_locale( bot: Throttle, q: CallbackQuery, diff --git a/src/callbacks/decrypt.rs b/src/callbacks/decrypt.rs index f1aa7b5..57c193c 100644 --- a/src/callbacks/decrypt.rs +++ b/src/callbacks/decrypt.rs @@ -2,7 +2,6 @@ use crate::{change_state, markups::account_markup, prelude::*}; use teloxide::types::ParseMode; use tokio::task::spawn_blocking; -#[inline] #[allow(clippy::too_many_arguments)] async fn get_master_pass( bot: Throttle, @@ -40,7 +39,6 @@ async fn get_master_pass( Ok(()) } -#[inline] pub async fn decrypt( bot: Throttle, q: CallbackQuery, diff --git a/src/callbacks/delete.rs b/src/callbacks/delete.rs index c0519f0..baf24e4 100644 --- a/src/callbacks/delete.rs +++ b/src/callbacks/delete.rs @@ -1,6 +1,5 @@ use crate::{change_state, prelude::*}; -#[inline] #[allow(clippy::too_many_arguments)] async fn get_master_pass( bot: Throttle, @@ -23,7 +22,6 @@ async fn get_master_pass( Ok(()) } -#[inline] pub async fn delete( bot: Throttle, q: CallbackQuery, diff --git a/src/callbacks/delete_message.rs b/src/callbacks/delete_message.rs index 0fe0362..27ed463 100644 --- a/src/callbacks/delete_message.rs +++ b/src/callbacks/delete_message.rs @@ -1,7 +1,6 @@ use crate::prelude::*; /// Deletes the message from the callback -#[inline] pub async fn delete_message( bot: Throttle, q: CallbackQuery, diff --git a/src/callbacks/get.rs b/src/callbacks/get.rs index 8521bc1..ed9d5c7 100644 --- a/src/callbacks/get.rs +++ b/src/callbacks/get.rs @@ -1,7 +1,6 @@ use crate::{markups::account_markup, prelude::*}; use teloxide::types::ParseMode; -#[inline] pub async fn get( bot: Throttle, q: CallbackQuery, diff --git a/src/callbacks/get_menu.rs b/src/callbacks/get_menu.rs index b2085d9..2f6c09e 100644 --- a/src/callbacks/get_menu.rs +++ b/src/callbacks/get_menu.rs @@ -1,6 +1,5 @@ use crate::prelude::*; -#[inline] pub async fn get_menu( bot: Throttle, q: CallbackQuery, diff --git a/src/commands/add_account.rs b/src/commands/add_account.rs index acce8c6..150209d 100644 --- a/src/commands/add_account.rs +++ b/src/commands/add_account.rs @@ -3,7 +3,6 @@ use tokio::task::spawn_blocking; /// Gets the name of the master password, encryptes the account and adds it to the DB #[allow(clippy::too_many_arguments)] -#[inline] async fn get_master_pass( bot: Throttle, msg: Message, diff --git a/src/commands/cancel.rs b/src/commands/cancel.rs index 294a1c5..092422e 100644 --- a/src/commands/cancel.rs +++ b/src/commands/cancel.rs @@ -1,7 +1,6 @@ use crate::prelude::*; /// Handles /cancel command when there's no active state -#[inline] pub async fn cancel(bot: Throttle, msg: Message, locale: LocaleRef) -> crate::Result<()> { bot.send_message(msg.chat.id, &locale.nothing_to_cancel) .reply_markup(deletion_markup(locale)) diff --git a/src/commands/change_language.rs b/src/commands/change_language.rs index 7d3aea1..5ce1c5d 100644 --- a/src/commands/change_language.rs +++ b/src/commands/change_language.rs @@ -1,6 +1,5 @@ use crate::{markups::language_markup, prelude::*}; -#[inline] pub async fn change_language( bot: Throttle, msg: Message, diff --git a/src/commands/delete.rs b/src/commands/delete.rs index e459056..57b5aba 100644 --- a/src/commands/delete.rs +++ b/src/commands/delete.rs @@ -1,6 +1,5 @@ use crate::prelude::*; -#[inline] pub async fn delete( bot: Throttle, msg: Message, diff --git a/src/commands/delete_all.rs b/src/commands/delete_all.rs index 2b3b44b..378a0fc 100644 --- a/src/commands/delete_all.rs +++ b/src/commands/delete_all.rs @@ -2,7 +2,6 @@ use crate::prelude::*; /// Gets the master password, deletes the accounts and the master password from DB. /// Although it doesn't use the master password, we get it to be sure that it's the user who used that command -#[inline] async fn get_master_pass( bot: Throttle, msg: Message, diff --git a/src/commands/export.rs b/src/commands/export.rs index eca1b0b..3b6b2a6 100644 --- a/src/commands/export.rs +++ b/src/commands/export.rs @@ -5,7 +5,6 @@ use teloxide::types::InputFile; use tokio::task::spawn_blocking; /// Decryptes the account on a worker thread and adds it to the accounts vector -#[inline] async fn decrypt_account( account: Account, master_pass: Arc, @@ -18,7 +17,6 @@ async fn decrypt_account( } /// Gets the master password, decryptes the account and sends the json file to the user -#[inline] async fn get_master_pass( bot: Throttle, msg: Message, diff --git a/src/commands/gen_password.rs b/src/commands/gen_password.rs index 6cfcf9e..6568a22 100644 --- a/src/commands/gen_password.rs +++ b/src/commands/gen_password.rs @@ -11,7 +11,6 @@ type PasswordArray = [ArrayString; AMOUNT_OF_PASSWORDS]; const BUFFER_LENGTH: usize = (PASSWORD_LENGTH + PASSWORD_PADDING_LENGTH) * AMOUNT_OF_PASSWORDS; /// Handles /`gen_password` command by generating 10 copyable passwords and sending them to the user -#[inline] pub async fn gen_password( bot: Throttle, msg: Message, diff --git a/src/commands/get_account.rs b/src/commands/get_account.rs index 726b03f..fcc236d 100644 --- a/src/commands/get_account.rs +++ b/src/commands/get_account.rs @@ -1,6 +1,5 @@ use crate::prelude::*; -#[inline] pub async fn get_account( bot: Throttle, msg: Message, diff --git a/src/commands/get_accounts.rs b/src/commands/get_accounts.rs index eadadf9..3fd9b21 100644 --- a/src/commands/get_accounts.rs +++ b/src/commands/get_accounts.rs @@ -3,7 +3,6 @@ use std::fmt::Write; use teloxide::types::ParseMode; /// Handles /`get_accounts` command by sending the list of copyable account names to the user -#[inline] pub async fn get_accounts( bot: Throttle, msg: Message, diff --git a/src/commands/help.rs b/src/commands/help.rs index b073820..7f85715 100644 --- a/src/commands/help.rs +++ b/src/commands/help.rs @@ -1,7 +1,6 @@ use crate::prelude::*; /// Handles the help command by sending the passwords descryptions -#[inline] pub async fn help(bot: Throttle, msg: Message, locale: LocaleRef) -> crate::Result<()> { bot.send_message(msg.chat.id, &locale.help_command) .reply_markup(deletion_markup(locale)) diff --git a/src/commands/import.rs b/src/commands/import.rs index 24d71fe..817f689 100644 --- a/src/commands/import.rs +++ b/src/commands/import.rs @@ -7,7 +7,6 @@ use tokio::task::spawn_blocking; /// Ecryptes the account and adds it to the database /// If any of these steps fail, the account name will be added to the failed vector -#[inline] async fn encrypt_account( account: DecryptedAccount, user_id: u64, @@ -26,7 +25,6 @@ async fn encrypt_account( } /// Gets the master password, encryptes and adds the accounts to the DB -#[inline] #[allow(clippy::too_many_arguments)] async fn get_master_pass( bot: Throttle, diff --git a/src/commands/menu.rs b/src/commands/menu.rs index 4ca176d..ba107ca 100644 --- a/src/commands/menu.rs +++ b/src/commands/menu.rs @@ -1,6 +1,5 @@ use crate::prelude::*; -#[inline] pub async fn menu( bot: Throttle, msg: Message, diff --git a/src/commands/set_master_pass.rs b/src/commands/set_master_pass.rs index 2ed659c..2465e91 100644 --- a/src/commands/set_master_pass.rs +++ b/src/commands/set_master_pass.rs @@ -4,7 +4,6 @@ use crate::{ }; use tokio::task::spawn_blocking; -#[inline] #[allow(clippy::too_many_arguments)] async fn get_master_pass2( bot: Throttle, @@ -50,7 +49,6 @@ async fn get_master_pass2( Ok(()) } -#[inline] async fn get_master_pass( bot: Throttle, _: Message, @@ -77,7 +75,6 @@ async fn get_master_pass( } /// Handles /`set_master_pass` command -#[inline] pub async fn set_master_pass( bot: Throttle, msg: Message, diff --git a/src/commands/start.rs b/src/commands/start.rs index ceb79c4..ededb30 100644 --- a/src/commands/start.rs +++ b/src/commands/start.rs @@ -1,7 +1,6 @@ use crate::prelude::*; /// Handles /start command by sending the greeting message -#[inline] pub async fn start(bot: Throttle, msg: Message, locale: LocaleRef) -> crate::Result<()> { bot.send_message(msg.chat.id, &locale.start_command).await?; Ok(()) diff --git a/src/cryptography.rs b/src/cryptography.rs index 9004a1e..7d07773 100644 --- a/src/cryptography.rs +++ b/src/cryptography.rs @@ -5,7 +5,6 @@ pub mod hashing; pub mod passwords; /// Returns true if the field is valid -#[inline] #[must_use] pub fn validate_field(field: &str) -> bool { if field.len() > 255 { diff --git a/src/cryptography/account.rs b/src/cryptography/account.rs index f6908e6..bc2536f 100644 --- a/src/cryptography/account.rs +++ b/src/cryptography/account.rs @@ -10,7 +10,6 @@ pub struct Cipher { impl Cipher { /// Creates a new cipher from a master password and the salt - #[inline] #[must_use] pub fn new(password: &[u8], salt: &[u8]) -> Self { let key = pbkdf2_hmac_array::(password, salt, 480_000); @@ -21,7 +20,6 @@ impl Cipher { } /// Encrypts the value with the current cipher. The 12 byte nonce is appended to the result - #[inline] pub fn encrypt(&self, value: &mut Vec) { let nonce = ChaCha20Poly1305::generate_nonce(&mut OsRng); self.chacha.encrypt_in_place(&nonce, b"", value).unwrap(); @@ -33,7 +31,6 @@ impl Cipher { /// # Errors /// /// Returns an error if the tag doesn't match the ciphertext - #[inline] #[allow(clippy::missing_panics_doc)] pub fn decrypt(&self, value: &mut Vec) -> super::Result<()> { if value.len() <= 12 { @@ -61,7 +58,6 @@ impl Decrypted { /// # Errors /// /// Returns an error if the tag doesn't match the ciphertext or if the decrypted data isn't valid UTF-8 - #[inline] pub fn from_account(mut account: Account, master_pass: &str) -> super::Result { let cipher = Cipher::new(master_pass.as_bytes(), &account.salt); cipher.decrypt(&mut account.enc_login)?; @@ -75,7 +71,6 @@ impl Decrypted { } /// Constructs `ActiveModel` with eath field Set by encrypting `self` - #[inline] #[must_use] pub fn into_account(self, user_id: u64, master_pass: &str) -> Account { let mut enc_login = self.login.into_bytes(); @@ -97,7 +92,6 @@ impl Decrypted { } /// Returns true if the account's fields are valid - #[inline] #[must_use] pub fn validate(&self) -> bool { [ diff --git a/src/cryptography/hashing.rs b/src/cryptography/hashing.rs index 899ea2e..bf7a18c 100644 --- a/src/cryptography/hashing.rs +++ b/src/cryptography/hashing.rs @@ -10,7 +10,6 @@ pub const SALT_LENGTH: usize = 64; static PARAMS: Lazy = Lazy::new(|| Params::new(14, 8, 1, HASH_LENGTH).unwrap()); /// Hashes the bytes with Scrypt with the given salt -#[inline] #[must_use] #[allow(clippy::missing_panics_doc)] pub fn hash_scrypt(bytes: &[u8], salt: &[u8]) -> [u8; HASH_LENGTH] { @@ -30,7 +29,6 @@ where } impl HashedBytes<[u8; HASH_LENGTH], [u8; SALT_LENGTH]> { - #[inline] #[must_use] pub fn new(bytes: &[u8]) -> Self { let mut salt = [0; 64]; @@ -47,7 +45,6 @@ where T: AsRef<[u8]>, U: AsRef<[u8]>, { - #[inline] #[must_use] pub fn verify(&self, bytes: &[u8]) -> bool { let hash = hash_scrypt(bytes, self.salt.as_ref()); @@ -56,7 +53,6 @@ where } impl<'a> From<&'a MasterPass> for HashedBytes<&'a [u8], &'a [u8]> { - #[inline] fn from(value: &'a MasterPass) -> Self { HashedBytes { hash: &value.password_hash, diff --git a/src/cryptography/passwords.rs b/src/cryptography/passwords.rs index 8bd397b..3ed3c90 100644 --- a/src/cryptography/passwords.rs +++ b/src/cryptography/passwords.rs @@ -24,7 +24,6 @@ bitflags::bitflags! { /// Returns true if the generated master password is valid. /// It checks that it has at least one lowercase, one uppercase, one number and one punctuation char -#[inline] #[must_use] fn check_generated_password(password: &[u8; LENGTH]) -> bool { let mut flags = PasswordFlags::empty(); @@ -46,7 +45,6 @@ fn check_generated_password(password: &[u8; LENGTH]) -> boo } /// Continuously generates the password until it passes the checks -#[inline] #[must_use] fn generate_password(rng: &mut R) -> ArrayString where @@ -60,7 +58,6 @@ where } } -#[inline] #[must_use] #[allow(clippy::module_name_repetitions)] pub fn generate_passwords( @@ -69,7 +66,6 @@ pub fn generate_passwords( array::from_fn(|_| generate_password(&mut rng)) } -#[inline] #[must_use] pub fn check_master_pass(password: &str) -> PasswordValidity { let mut count = 0; diff --git a/src/dispatching/default.rs b/src/dispatching/default.rs index 3585969..766763b 100644 --- a/src/dispatching/default.rs +++ b/src/dispatching/default.rs @@ -1,7 +1,6 @@ use crate::prelude::*; /// Handles the messages which weren't matched by any commands or states -#[inline] pub async fn default(bot: Throttle, msg: Message, locale: LocaleRef) -> crate::Result<()> { bot.send_message(msg.chat.id, &locale.unknown_command_use_help) .reply_markup(deletion_markup(locale)) diff --git a/src/dispatching/delete_mesage_handler.rs b/src/dispatching/delete_mesage_handler.rs index 794d2b3..7e477d2 100644 --- a/src/dispatching/delete_mesage_handler.rs +++ b/src/dispatching/delete_mesage_handler.rs @@ -1,7 +1,6 @@ use crate::prelude::*; /// Deletes the message without returning errors -#[inline] pub async fn delete_message(bot: Throttle, msg: Message) { let ids = MessageIds::from(&msg); if let Err(err) = ids.delete(&bot).await { diff --git a/src/dispatching/filter_user_info.rs b/src/dispatching/filter_user_info.rs index e959c62..d6d1bc0 100644 --- a/src/dispatching/filter_user_info.rs +++ b/src/dispatching/filter_user_info.rs @@ -1,13 +1,11 @@ use crate::prelude::*; use teloxide::{dispatching::DpHandlerDescription, dptree::Handler}; -#[inline] #[allow(clippy::needless_pass_by_value)] fn has_no_user_info(msg: Message) -> bool { msg.from().is_none() } -#[inline] async fn notify_about_no_user_info( bot: Throttle, msg: Message, @@ -48,7 +46,6 @@ async fn notify_about_no_user_info( } /// Gets a handler that filters out the messages without user information -#[inline] pub fn get_handler() -> Handler<'static, DependencyMap, crate::Result<()>, DpHandlerDescription> { dptree::filter(has_no_user_info).endpoint(notify_about_no_user_info) } diff --git a/src/dispatching/master_password_check.rs b/src/dispatching/master_password_check.rs index a708bbd..2f8f4b7 100644 --- a/src/dispatching/master_password_check.rs +++ b/src/dispatching/master_password_check.rs @@ -13,7 +13,6 @@ type DynError = Arc; /// /// Returns None if account exists, Some(None) if there's an account and Some(Some(DynError)) if an error occures. /// The String represents the error that occured -#[inline] async fn master_pass_exists(update: Update, db: Pool) -> Option> { let user_id = match update.user() { Some(user) => user.id.0, @@ -26,7 +25,6 @@ async fn master_pass_exists(update: Update, db: Pool) -> Option } } -#[inline] async fn notify_about_no_master_pass( bot: Throttle, locale: LocaleRef, @@ -46,7 +44,6 @@ async fn notify_about_no_master_pass( } /// Gets a handler that filters out the messages of users that don't have a master password set -#[inline] pub fn get_handler() -> Handler<'static, DependencyMap, crate::Result<()>, DpHandlerDescription> { dptree::filter_map_async(master_pass_exists).endpoint(notify_about_no_master_pass) } diff --git a/src/entity/account.rs b/src/entity/account.rs index 45189b0..2af2c38 100644 --- a/src/entity/account.rs +++ b/src/entity/account.rs @@ -13,7 +13,6 @@ pub struct Account { impl Account { // Inserts the account into DB - #[inline] pub async fn insert(&self, pool: &Pool) -> super::Result<()> { query!( "INSERT INTO account VALUES (?, ?, ?, ?, ?)", @@ -29,7 +28,6 @@ impl Account { } /// Gets all user's account from DB - #[inline] pub fn get_all(user_id: u64, pool: &Pool) -> impl Stream> + '_ { query_as("SELECT * FROM account WHERE user_id = ?") .bind(user_id) @@ -37,7 +35,6 @@ impl Account { } /// Streams the names of the user accounts - #[inline] pub fn get_names(user_id: u64, pool: &Pool) -> impl Stream> + '_ { query_as::<_, (String,)>("SELECT name FROM account WHERE user_id = ? ORDER BY name") .bind(user_id) @@ -46,7 +43,6 @@ impl Account { } /// Checks if the account exists - #[inline] pub async fn exists(user_id: u64, account_name: &str, pool: &Pool) -> super::Result { query_as::<_, (bool,)>( "SELECT EXISTS(SELECT * FROM account WHERE user_id = ? AND name = ? LIMIT 1) as value", @@ -59,7 +55,6 @@ impl Account { } /// Gets the account from the DB - #[inline] pub async fn get(user_id: u64, account_name: &str, pool: &Pool) -> super::Result> { query_as("SELECT * FROM account WHERE user_id = ? AND name = ?") .bind(user_id) @@ -69,7 +64,6 @@ impl Account { } // Deletes the account from DB - #[inline] pub async fn delete(user_id: u64, name: &str, pool: &Pool) -> super::Result<()> { query!( "DELETE FROM account WHERE user_id = ? AND name = ?", @@ -82,7 +76,6 @@ impl Account { } /// Deletes all the user's accounts from DB - #[inline] pub async fn delete_all( user_id: u64, pool: impl Executor<'_, Database = MySql>, @@ -94,7 +87,6 @@ impl Account { } /// Gets a name by a SHA256 hash of the name - #[inline] pub async fn get_name_by_hash( user_id: u64, hash: &[u8], @@ -111,8 +103,6 @@ impl Account { Ok(name.map(|(name,)| name)) } - - #[inline] pub async fn get_salt(user_id: u64, name: &str, pool: &Pool) -> super::Result>> { let salt = query_as::<_, (Vec,)>("SELECT salt FROM account WHERE user_id = ? AND name = ?") @@ -123,8 +113,6 @@ impl Account { Ok(salt.map(|(salt,)| salt)) } - - #[inline] pub async fn update_name( user_id: u64, original_name: &str, @@ -141,8 +129,6 @@ impl Account { .await .map(|result| result.rows_affected() != 0) } - - #[inline] pub async fn update_login( user_id: u64, name: &str, @@ -159,8 +145,6 @@ impl Account { .await .map(|result| result.rows_affected() != 0) } - - #[inline] pub async fn update_password( user_id: u64, name: &str, diff --git a/src/entity/master_pass.rs b/src/entity/master_pass.rs index c9cba4d..176d6a4 100644 --- a/src/entity/master_pass.rs +++ b/src/entity/master_pass.rs @@ -10,7 +10,6 @@ pub struct MasterPass { impl MasterPass { // Inserts the master password into DB - #[inline] pub async fn insert(&self, pool: &Pool, locale: LocaleType) -> super::Result<()> { let locale: u8 = locale.into(); query!( @@ -26,7 +25,6 @@ impl MasterPass { } /// Gets the master password from the database - #[inline] pub async fn get(user_id: u64, pool: &Pool) -> super::Result> { query_as("SELECT user_id, salt, password_hash FROM master_pass WHERE user_id = ?") .bind(user_id) @@ -35,7 +33,6 @@ impl MasterPass { } /// Checks if the master password for the user exists - #[inline] pub async fn exists(user_id: u64, pool: &Pool) -> super::Result { query_as::<_, (bool,)>( "SELECT EXISTS(SELECT * FROM master_pass WHERE user_id = ? LIMIT 1) as value", diff --git a/src/errors.rs b/src/errors.rs index a813c10..dc180a7 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -21,7 +21,6 @@ pub enum InvalidCommand { UnknownLocale, } -#[inline] pub fn init_logger() { tracing_subscriber::registry() .with(fmt::layer().pretty()) @@ -32,7 +31,6 @@ pub fn init_logger() { /// Handles an error. /// This function must be as cheap and generic as possible and must remain sync. /// If expensive or long action is required, a task should be spawned but not joined. -#[inline] pub fn handle_error(error: T) where T: Debug + Display, @@ -43,7 +41,6 @@ where pub struct ErrorHandler; impl teloxide::error_handlers::ErrorHandler for ErrorHandler { - #[inline] fn handle_error( self: std::sync::Arc, error: crate::Error, diff --git a/src/macros.rs b/src/macros.rs index a31a821..a84dc2d 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -13,7 +13,6 @@ macro_rules! change_state { #[macro_export] macro_rules! first_handler { ($function_name: ident, $message: ident, $next_state: expr, $next_func: ident) => { - #[inline] pub async fn $function_name( bot: Throttle, msg: Message, @@ -33,7 +32,6 @@ macro_rules! first_handler { macro_rules! handler { ($function_name: ident ($($param: ident: $type: ty),*), $message: ident, $next_state: expr, $next_func: ident) => { #[allow(clippy::too_many_arguments)] - #[inline] async fn $function_name( bot: Throttle, _: Message, @@ -55,7 +53,6 @@ macro_rules! handler { #[macro_export] macro_rules! simple_state_handler { ($function_name: ident, $check: ident) => { - #[inline] pub async fn $function_name( bot: Throttle, msg: Message, diff --git a/src/markups.rs b/src/markups.rs index 04173c0..9d0bd7e 100644 --- a/src/markups.rs +++ b/src/markups.rs @@ -5,7 +5,6 @@ use sha2::{Digest, Sha256}; use teloxide::types::{InlineKeyboardButton, InlineKeyboardMarkup}; use tokio::task::spawn_blocking; -#[inline] pub fn menu_markup_sync( command: &str, names: impl IntoIterator, @@ -25,7 +24,6 @@ pub fn menu_markup_sync( InlineKeyboardMarkup::new(&names) } -#[inline] pub async fn menu_markup( command: impl Into + Send, user_id: u64, @@ -39,7 +37,6 @@ pub async fn menu_markup( .map_err(Into::into) } -#[inline] fn make_button(text: &str, command: &str, param: &str) -> InlineKeyboardButton { let mut data = command.to_owned(); data.reserve(param.len() + 1); @@ -48,7 +45,6 @@ fn make_button(text: &str, command: &str, param: &str) -> InlineKeyboardButton { InlineKeyboardButton::callback(text, data) } -#[inline] pub fn account_markup(name: &str, is_encrypted: bool, locale: LocaleRef) -> InlineKeyboardMarkup { let mut hash = [0; 43]; B64_ENGINE @@ -78,7 +74,6 @@ pub fn account_markup(name: &str, is_encrypted: bool, locale: LocaleRef) -> Inli InlineKeyboardMarkup::new(&main_buttons).append_row([menu_button]) } -#[inline] pub fn language_markup() -> InlineKeyboardMarkup { let languages = [("🇷🇺 Русский", "ru"), ("🇬🇧 English", "en")] .into_iter() @@ -89,7 +84,6 @@ pub fn language_markup() -> InlineKeyboardMarkup { /// Creates a markup with a "Delete message" button. /// This markup should be added for all messages that won't be deleted afterwards -#[inline] pub fn deletion_markup(locale: LocaleRef) -> InlineKeyboardMarkup { let button = InlineKeyboardButton::callback(&locale.delete_message_button, "delete_message"); InlineKeyboardMarkup::new([[button]]) diff --git a/src/state/generic.rs b/src/state/generic.rs index ca57211..38f67cb 100644 --- a/src/state/generic.rs +++ b/src/state/generic.rs @@ -2,7 +2,6 @@ use crate::{errors::HandlerUsed, prelude::*}; use futures::future::BoxFuture; /// A generic state handler. It checks for "/cancel" messages and runs the provided validation function -#[inline] pub async fn generic( bot: Throttle, msg: Message, diff --git a/src/state/get_login.rs b/src/state/get_login.rs index 6897882..a20e39f 100644 --- a/src/state/get_login.rs +++ b/src/state/get_login.rs @@ -1,6 +1,5 @@ use crate::prelude::*; -#[inline] async fn check_login( _: &Message, _: &Pool, diff --git a/src/state/get_master_pass.rs b/src/state/get_master_pass.rs index b9b89e4..a4e7ea1 100644 --- a/src/state/get_master_pass.rs +++ b/src/state/get_master_pass.rs @@ -2,7 +2,6 @@ use crate::{cryptography::hashing::HashedBytes, prelude::*}; use tokio::task::spawn_blocking; /// Returns true if the provided master password is valid -#[inline] async fn check_master_pass( msg: &Message, db: &Pool, diff --git a/src/state/get_new_master_pass.rs b/src/state/get_new_master_pass.rs index 8104e13..7aec208 100644 --- a/src/state/get_new_master_pass.rs +++ b/src/state/get_new_master_pass.rs @@ -4,7 +4,6 @@ use crate::{ }; use std::fmt::Write as _; -#[inline] fn process_validity(validity: PasswordValidity, locale: LocaleRef) -> Result<(), String> { if validity.is_empty() { return Ok(()); @@ -39,7 +38,6 @@ fn process_validity(validity: PasswordValidity, locale: LocaleRef) -> Result<(), } /// Checks that the account with that name exists -#[inline] async fn check_new_master_pass( _: &Message, _: &Pool, diff --git a/src/state/get_new_name.rs b/src/state/get_new_name.rs index 1d96e93..3a90ef3 100644 --- a/src/state/get_new_name.rs +++ b/src/state/get_new_name.rs @@ -1,7 +1,6 @@ use crate::prelude::*; /// Validates a new account -#[inline] async fn check_new_account_name( msg: &Message, db: &Pool, diff --git a/src/state/get_password.rs b/src/state/get_password.rs index b1c9ea1..14f92e4 100644 --- a/src/state/get_password.rs +++ b/src/state/get_password.rs @@ -1,6 +1,5 @@ use crate::prelude::*; -#[inline] async fn check_password( _: &Message, _: &Pool, diff --git a/src/state/get_user.rs b/src/state/get_user.rs index 464320a..2dec0b4 100644 --- a/src/state/get_user.rs +++ b/src/state/get_user.rs @@ -28,7 +28,6 @@ impl InvalidDocument { } } -#[inline] fn validate_document(document: Option<&Document>) -> Result<&Document, InvalidDocument> { let Some(document) = document else { return Err(InvalidDocument::NoFileSend); @@ -49,7 +48,6 @@ fn validate_document(document: Option<&Document>) -> Result<&Document, InvalidDo } } -#[inline] async fn download_file(bot: &Throttle, file: &FileMeta) -> crate::Result> { let path = bot.get_file(&file.id).await?.path; let mut data = Vec::with_capacity(file.size as usize); @@ -60,7 +58,6 @@ async fn download_file(bot: &Throttle, file: &FileMeta) -> crate::Result, @@ -136,7 +133,6 @@ fn process_accounts( Ok(Err(error_text)) } -#[inline] fn user_from_bytes( bytes: impl AsRef<[u8]>, existing_names: ahash::HashSet, @@ -150,7 +146,6 @@ fn user_from_bytes( } } -#[inline] async fn user_from_document( bot: &Throttle, db: &Pool, @@ -178,7 +173,6 @@ async fn user_from_document( } /// Function to handle `GetUser` state. It doesn't actually validate anything -#[inline] pub async fn get_user( bot: Throttle, msg: Message, diff --git a/src/state/handler.rs b/src/state/handler.rs index 77d6f60..a662c6c 100644 --- a/src/state/handler.rs +++ b/src/state/handler.rs @@ -13,7 +13,6 @@ pub struct MessageIds(pub ChatId, pub MessageId); impl MessageIds { // Tries to delete the message while ignoring API errors - #[inline] pub async fn delete(self, bot: &Throttle) -> Result<(), RequestError> { match bot.delete_message(self.0, self.1).await { Ok(_) | Err(RequestError::Api(_)) => Ok(()), @@ -22,7 +21,6 @@ impl MessageIds { } /// Tries to alter the message or sends a new one - #[inline] pub async fn alter_message( &mut self, bot: &Throttle, @@ -55,7 +53,6 @@ impl MessageIds { } impl From<&Message> for MessageIds { - #[inline] fn from(value: &Message) -> Self { Self(value.chat.id, value.id) } @@ -84,7 +81,6 @@ pub type Packaged = Arc>>; impl Handler { /// Convinience method to convert a simple async function and a previous message into `PackagedHandler` - #[inline] pub fn new(f: H, previous: impl Into) -> PackagedHandler where H: FnOnce(