From 14ec768b4520d4fc34dbf24e663ea7db940c18b7 Mon Sep 17 00:00:00 2001 From: Ellie Huxtable Date: Wed, 19 Mar 2025 12:44:20 +0000 Subject: chore: migrate to rust 2024 (#2635) * chore: upgrade to 2024 edition * ugh unsafe * format * nixxxxxxxxxxx why --- crates/atuin-client/src/login.rs | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) (limited to 'crates/atuin-client/src/login.rs') diff --git a/crates/atuin-client/src/login.rs b/crates/atuin-client/src/login.rs index 05303464..78168c7e 100644 --- a/crates/atuin-client/src/login.rs +++ b/crates/atuin-client/src/login.rs @@ -1,13 +1,13 @@ use std::path::PathBuf; use atuin_common::api::LoginRequest; -use eyre::{bail, Context, Result}; +use eyre::{Context, Result, bail}; use tokio::fs::File; use tokio::io::AsyncWriteExt; use crate::{ api_client, - encryption::{decode_key, encode_key, load_key, Key}, + encryption::{Key, decode_key, encode_key, load_key}, record::{sqlite_store::SqliteStore, store::Store}, settings::Settings, }; @@ -23,22 +23,25 @@ pub async fn login( let key = match bip39::Mnemonic::from_phrase(&key, bip39::Language::English) { Ok(mnemonic) => encode_key(Key::from_slice(mnemonic.entropy()))?, Err(err) => { - if let Some(err) = err.downcast_ref::() { - match err { - // assume they copied in the base64 key - bip39::ErrorKind::InvalidWord => key, - bip39::ErrorKind::InvalidChecksum => { - bail!("key mnemonic was not valid") - } - bip39::ErrorKind::InvalidKeysize(_) - | bip39::ErrorKind::InvalidWordLength(_) - | bip39::ErrorKind::InvalidEntropyLength(_, _) => { - bail!("key was not the correct length") + match err.downcast_ref::() { + Some(err) => { + match err { + // assume they copied in the base64 key + bip39::ErrorKind::InvalidWord => key, + bip39::ErrorKind::InvalidChecksum => { + bail!("key mnemonic was not valid") + } + bip39::ErrorKind::InvalidKeysize(_) + | bip39::ErrorKind::InvalidWordLength(_) + | bip39::ErrorKind::InvalidEntropyLength(_, _) => { + bail!("key was not the correct length") + } } } - } else { - // unknown error. assume they copied the base64 key - key + _ => { + // unknown error. assume they copied the base64 key + key + } } } }; -- cgit v1.3.1