Added MORE inlines

This commit is contained in:
StNicolay 2023-08-07 13:38:46 +03:00
parent 857f268f1d
commit 2199889127
Signed by: StNicolay
GPG Key ID: 9693D04DCD962B0D
21 changed files with 23 additions and 0 deletions

View File

@ -76,6 +76,7 @@ async fn get_master_pass(
handler!(get_field(name:String, field:AlterableField, field_value:String), "Send the master password", State::GetMasterPass, get_master_pass); handler!(get_field(name:String, field:AlterableField, field_value:String), "Send the master password", State::GetMasterPass, get_master_pass);
#[inline]
pub async fn alter( pub async fn alter(
bot: Throttle<Bot>, bot: Throttle<Bot>,
q: CallbackQuery, q: CallbackQuery,

View File

@ -39,6 +39,7 @@ async fn get_master_pass(
Ok(()) Ok(())
} }
#[inline]
pub async fn decrypt( pub async fn decrypt(
bot: Throttle<Bot>, bot: Throttle<Bot>,
q: CallbackQuery, q: CallbackQuery,

View File

@ -26,6 +26,7 @@ async fn get_master_pass(
Ok(()) Ok(())
} }
#[inline]
pub async fn delete( pub async fn delete(
bot: Throttle<Bot>, bot: Throttle<Bot>,
q: CallbackQuery, q: CallbackQuery,

View File

@ -1,6 +1,7 @@
use crate::prelude::*; use crate::prelude::*;
/// Deletes the message from the callback /// Deletes the message from the callback
#[inline]
pub async fn delete_message(bot: Throttle<Bot>, q: CallbackQuery) -> crate::Result<()> { pub async fn delete_message(bot: Throttle<Bot>, q: CallbackQuery) -> crate::Result<()> {
if let Some(msg) = q.message { if let Some(msg) = q.message {
if bot.delete_message(msg.chat.id, msg.id).await.is_err() { if bot.delete_message(msg.chat.id, msg.id).await.is_err() {

View File

@ -1,6 +1,7 @@
use crate::prelude::*; use crate::prelude::*;
use teloxide::types::ParseMode; use teloxide::types::ParseMode;
#[inline]
pub async fn get( pub async fn get(
bot: Throttle<Bot>, bot: Throttle<Bot>,
q: CallbackQuery, q: CallbackQuery,

View File

@ -1,5 +1,6 @@
use crate::prelude::*; use crate::prelude::*;
#[inline]
pub async fn get_menu( pub async fn get_menu(
bot: Throttle<Bot>, bot: Throttle<Bot>,
q: CallbackQuery, q: CallbackQuery,

View File

@ -3,6 +3,7 @@ use tokio::task::spawn_blocking;
/// Gets the name of the master password, encryptes the account and adds it to the DB /// Gets the name of the master password, encryptes the account and adds it to the DB
#[allow(clippy::too_many_arguments)] #[allow(clippy::too_many_arguments)]
#[inline]
async fn get_master_pass( async fn get_master_pass(
bot: Throttle<Bot>, bot: Throttle<Bot>,
msg: Message, msg: Message,

View File

@ -1,6 +1,7 @@
use crate::prelude::*; use crate::prelude::*;
/// Handles /cancel command when there's no active state /// Handles /cancel command when there's no active state
#[inline]
pub async fn cancel(bot: Throttle<Bot>, msg: Message) -> crate::Result<()> { pub async fn cancel(bot: Throttle<Bot>, msg: Message) -> crate::Result<()> {
bot.send_message(msg.chat.id, "Nothing to cancel") bot.send_message(msg.chat.id, "Nothing to cancel")
.reply_markup(deletion_markup()) .reply_markup(deletion_markup())

View File

@ -1,5 +1,6 @@
use crate::prelude::*; use crate::prelude::*;
#[inline]
pub async fn delete(bot: Throttle<Bot>, msg: Message, db: DatabaseConnection) -> crate::Result<()> { pub async fn delete(bot: Throttle<Bot>, msg: Message, db: DatabaseConnection) -> crate::Result<()> {
let user_id = msg.from().ok_or(NoUserInfo)?.id.0; let user_id = msg.from().ok_or(NoUserInfo)?.id.0;

View File

@ -5,6 +5,7 @@ use tokio::try_join;
/// Gets the master password, deletes the accounts and the master password from DB. /// 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 /// 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( async fn get_master_pass(
bot: Throttle<Bot>, bot: Throttle<Bot>,
msg: Message, msg: Message,

View File

@ -18,6 +18,7 @@ async fn decrypt_account(
} }
/// Gets the master password, decryptes the account and sends the json file to the user /// Gets the master password, decryptes the account and sends the json file to the user
#[inline]
async fn get_master_pass( async fn get_master_pass(
bot: Throttle<Bot>, bot: Throttle<Bot>,
msg: Message, msg: Message,

View File

@ -14,6 +14,7 @@ const BUFFER_LENGTH: usize =
MESSAGE_HEADER.len() + (PASSWORD_LENGTH + PASSWORD_PADDING_LENGTH) * AMOUNT_OF_PASSWORDS; MESSAGE_HEADER.len() + (PASSWORD_LENGTH + PASSWORD_PADDING_LENGTH) * AMOUNT_OF_PASSWORDS;
/// Handles /gen_password command by generating 10 copyable passwords and sending them to the user /// Handles /gen_password command by generating 10 copyable passwords and sending them to the user
#[inline]
pub async fn gen_password(bot: Throttle<Bot>, msg: Message) -> crate::Result<()> { pub async fn gen_password(bot: Throttle<Bot>, msg: Message) -> crate::Result<()> {
let mut message: ArrayString<BUFFER_LENGTH> = MESSAGE_HEADER.try_into().unwrap(); let mut message: ArrayString<BUFFER_LENGTH> = MESSAGE_HEADER.try_into().unwrap();
let passwords: PasswordArray = spawn_blocking(generate_passwords).await?; let passwords: PasswordArray = spawn_blocking(generate_passwords).await?;

View File

@ -1,5 +1,6 @@
use crate::prelude::*; use crate::prelude::*;
#[inline]
pub async fn get_account( pub async fn get_account(
bot: Throttle<Bot>, bot: Throttle<Bot>,
msg: Message, msg: Message,

View File

@ -4,6 +4,7 @@ use std::fmt::Write;
use teloxide::types::ParseMode; use teloxide::types::ParseMode;
/// Handles /get_accounts command by sending the list of copyable account names to the user /// Handles /get_accounts command by sending the list of copyable account names to the user
#[inline]
pub async fn get_accounts( pub async fn get_accounts(
bot: Throttle<Bot>, bot: Throttle<Bot>,
msg: Message, msg: Message,

View File

@ -2,6 +2,7 @@ use crate::prelude::*;
use teloxide::utils::command::BotCommands; use teloxide::utils::command::BotCommands;
/// Handles the help command by sending the passwords descryptions /// Handles the help command by sending the passwords descryptions
#[inline]
pub async fn help(bot: Throttle<Bot>, msg: Message) -> crate::Result<()> { pub async fn help(bot: Throttle<Bot>, msg: Message) -> crate::Result<()> {
bot.send_message(msg.chat.id, Command::descriptions().to_string()) bot.send_message(msg.chat.id, Command::descriptions().to_string())
.reply_markup(deletion_markup()) .reply_markup(deletion_markup())

View File

@ -26,6 +26,7 @@ async fn encrypt_account(
} }
/// Gets the master password, encryptes and adds the accounts to the DB /// Gets the master password, encryptes and adds the accounts to the DB
#[inline]
async fn get_master_pass( async fn get_master_pass(
bot: Throttle<Bot>, bot: Throttle<Bot>,
msg: Message, msg: Message,

View File

@ -1,6 +1,7 @@
use crate::prelude::*; use crate::prelude::*;
use tokio::task::spawn_blocking; use tokio::task::spawn_blocking;
#[inline]
pub async fn menu(bot: Throttle<Bot>, msg: Message, db: DatabaseConnection) -> crate::Result<()> { pub async fn menu(bot: Throttle<Bot>, msg: Message, db: DatabaseConnection) -> crate::Result<()> {
let user_id = msg.from().ok_or(NoUserInfo)?.id.0; let user_id = msg.from().ok_or(NoUserInfo)?.id.0;

View File

@ -3,6 +3,7 @@ use cryptography::hashing::HashedBytes;
use sea_orm::ActiveValue::Set; use sea_orm::ActiveValue::Set;
use tokio::task::spawn_blocking; use tokio::task::spawn_blocking;
#[inline]
async fn get_master_pass2( async fn get_master_pass2(
bot: Throttle<Bot>, bot: Throttle<Bot>,
msg: Message, msg: Message,
@ -66,6 +67,7 @@ async fn get_master_pass(
} }
/// Handles /set_master_pass command /// Handles /set_master_pass command
#[inline]
pub async fn set_master_pass( pub async fn set_master_pass(
bot: Throttle<Bot>, bot: Throttle<Bot>,
msg: Message, msg: Message,

View File

@ -1,6 +1,7 @@
use crate::prelude::*; use crate::prelude::*;
/// Handles /start command by sending the greeting message /// Handles /start command by sending the greeting message
#[inline]
pub async fn start(bot: Throttle<Bot>, msg: Message) -> crate::Result<()> { pub async fn start(bot: Throttle<Bot>, msg: Message) -> crate::Result<()> {
bot.send_message( bot.send_message(
msg.chat.id, msg.chat.id,

View File

@ -1,6 +1,7 @@
use crate::prelude::*; use crate::prelude::*;
/// Handles the messages which weren't matched by any commands or states /// Handles the messages which weren't matched by any commands or states
#[inline]
pub async fn default(bot: Throttle<Bot>, msg: Message) -> crate::Result<()> { pub async fn default(bot: Throttle<Bot>, msg: Message) -> crate::Result<()> {
bot.send_message( bot.send_message(
msg.chat.id, msg.chat.id,

View File

@ -8,6 +8,7 @@ use teloxide::{dispatching::DpHandlerDescription, dptree::Handler};
/// ///
/// Returns None if account exists, Some(None) if there's an account and Some(Some(String)) if an error occures. /// Returns None if account exists, Some(None) if there's an account and Some(Some(String)) if an error occures.
/// The String represents the error that occured /// The String represents the error that occured
#[inline]
async fn master_pass_exists( async fn master_pass_exists(
msg: Message, msg: Message,
db: DatabaseConnection, db: DatabaseConnection,
@ -23,6 +24,7 @@ async fn master_pass_exists(
} }
} }
#[inline]
async fn notify_about_no_master_pass( async fn notify_about_no_master_pass(
bot: Throttle<Bot>, bot: Throttle<Bot>,
result: Option<Arc<dyn std::error::Error + Send + Sync>>, result: Option<Arc<dyn std::error::Error + Send + Sync>>,