pub async fn remove_alias(
        &mut self,
        chat_id: i64,
        alias: &str,
    ) -> Result<(), RedisStorageError> {
        let key: String = RedisConnection::get_aliases_key(chat_id);
        let n_removed: i64 = self.connection.hdel(key, alias).await.map_err(|e| {
            log::info!(
                "{}",
                format_log_chat(&format!("Failed to remove alias from DB: {}", e), chat_id)
            );
            RedisStorageError::RedisError(e)
        })?;
        // Log and form result
        match n_removed {
            0 => {
                log::info!(
                    "{}",
                    format_log_chat(&format!("Alias '{a}' was not found", a = alias), chat_id)
                );
                Err(RedisStorageError::AliasNotFound)
            }
            1 => {
                log::info!(
                    "{}",
                    format_log_chat(&format!("Removed alias '{a}'", a = alias), chat_id)
                );
                Ok(())
            }
            n_unexpected => {
                log::warn!(
                    "{}",
                    format_log_chat(
                        &format!(
                            "'{a}' removal returned unexpected number: {n}",
                            a = alias,
                            n = n_unexpected
                        ),
                        chat_id
                    )
                );
                Ok(())
            }
        }
    }
/// Unmap (remove) the alias for given chat id.
Unmap (remove) the alias for given chat id.
Unmap ( remove ) the alias for given chat id .
pub async fn remove_alias(
        &mut self,
        chat_id: i64,
        alias: &str,
    ) -> Result<(), RedisStorageError> {
        let key: String = RedisConnection::get_aliases_key(chat_id);
        let n_removed: i64 = self.connection.hdel(key, alias).await.map_err(|e| {
            log::info!(
                "{}",
                format_log_chat(&format!("Failed to remove alias from DB: {}", e), chat_id)
            );
            RedisStorageError::RedisError(e)
        })?;
        // Log and form result
        match n_removed {
            0 => {
                log::info!(
                    "{}",
                    format_log_chat(&format!("Alias '{a}' was not found", a = alias), chat_id)
                );
                Err(RedisStorageError::AliasNotFound)
            }
            1 => {
                log::info!(
                    "{}",
                    format_log_chat(&format!("Removed alias '{a}'", a = alias), chat_id)
                );
                Ok(())
            }
            n_unexpected => {
                log::warn!(
                    "{}",
                    format_log_chat(
                        &format!(
                            "'{a}' removal returned unexpected number: {n}",
                            a = alias,
                            n = n_unexpected
                        ),
                        chat_id
                    )
                );
                Ok(())
            }
        }
    }
pub async fn remove_alias ( & mut self , chat_id : i64 , alias : & str , ) -> Result < ( ) , RedisStorageError > { let key : String = RedisConnection :: get_aliases_key ( chat_id ) ; let n_removed : i64 = self . connection . hdel ( key , alias ) . await . map_err ( | e | { log :: info ! ( " " format_log_chat ( format ( " " e ) chat_id ) ) ; RedisStorageError :: RedisError ( e ) } ) ? ; // Log and form result match n_removed { 0 => { log :: info ! ( " " format_log_chat ( format ( " " a alias ) chat_id ) ) ; Err ( RedisStorageError :: AliasNotFound ) } 1 => { log :: info ! ( " " format_log_chat ( format ( " " a alias ) chat_id ) ) ; Ok ( ( ) ) } n_unexpected => { log :: warn ! ( " " format_log_chat ( format ( " " a alias n n_unexpected ) chat_id ) ) ; Ok ( ( ) ) } } }
Unmap (remove) the alias for given chat id.
Unmap ( remove ) the alias for given chat id .
&mut self
chat_id
i64
alias
&str