pub async fn hash_password(password: String) -> Result<String, anyhow::Error> {
    // Argon2 hashing is designed to be computationally intensive,
    // so we need to do this on a blocking thread.
    Ok(tokio::task::spawn_blocking(move || -> Result<String, anyhow::Error> {
        let salt = SaltString::generate(rand::thread_rng());
        Ok(
            PasswordHash::generate(Argon2::default(), password, salt.as_str())
                .map_err(|e| anyhow::anyhow!("failed to generate password hash: {}", e))?
                .to_string(),
        )
    })
        .await
        .context("panic in generating password hash")??)
}
///
/// Utility function to hash passwords
/// Returns a String with hashed password or anyhow::Error
///

Utility function to hash passwords
Returns a String with hashed password or anyhow::Error
Utility function to hash passwords Returns a String with hashed password or anyhow :: Error
pub async fn hash_password(password: String) -> Result<String, anyhow::Error> {
    // Argon2 hashing is designed to be computationally intensive,
    // so we need to do this on a blocking thread.
    Ok(tokio::task::spawn_blocking(move || -> Result<String, anyhow::Error> {
        let salt = SaltString::generate(rand::thread_rng());
        Ok(
            PasswordHash::generate(Argon2::default(), password, salt.as_str())
                .map_err(|e| anyhow::anyhow!("failed to generate password hash: {}", e))?
                .to_string(),
        )
    })
        .await
        .context("panic in generating password hash")??)
}
pub async fn hash_password ( password : String ) -> Result < String , anyhow :: Error > { // Argon2 hashing is designed to be computationally intensive,
 // so we need to do this on a blocking thread.
 Ok ( tokio :: task :: spawn_blocking ( move | | -> Result < String , anyhow :: Error > { let salt = SaltString :: generate ( rand :: thread_rng ( ) ) ; Ok ( PasswordHash :: generate ( Argon2 :: default ( ) , password , salt . as_str ( ) ) . map_err ( | e | anyhow :: anyhow ! ( " " e ) ) ? . to_string ( ) , ) } ) . await . context ( " " ) ? ? ) }
Utility function to hash passwords
Returns a String with hashed password or anyhow::Error
Utility function to hash passwords Returns a String with hashed password or anyhow :: Error
password
String