From 293c7d0aa3a8af921a194f821124996f6b5d8956 Mon Sep 17 00:00:00 2001 From: yggverse Date: Sat, 14 Dec 2024 07:04:23 +0200 Subject: [PATCH] enshort to common variable name --- .../window/tab/item/identity/gemini.rs | 12 +++++----- .../item/identity/gemini/widget/form/file.rs | 8 +++---- .../gemini/widget/form/save/certificate.rs | 4 ++-- src/profile.rs | 24 +++++++++---------- src/profile/bookmark.rs | 6 ++--- src/profile/bookmark/database.rs | 6 ++--- src/profile/identity.rs | 10 ++++---- src/profile/identity/database.rs | 2 +- src/profile/identity/error.rs | 8 +++---- src/profile/identity/gemini.rs | 20 ++++++++-------- src/profile/identity/gemini/auth.rs | 24 +++++++++---------- src/profile/identity/gemini/auth/database.rs | 4 ++-- src/profile/identity/gemini/auth/error.rs | 4 ++-- src/profile/identity/gemini/database.rs | 4 ++-- src/profile/identity/gemini/identity.rs | 2 +- 15 files changed, 69 insertions(+), 69 deletions(-) diff --git a/src/app/browser/window/tab/item/identity/gemini.rs b/src/app/browser/window/tab/item/identity/gemini.rs index bfa2cb30..cba9138b 100644 --- a/src/app/browser/window/tab/item/identity/gemini.rs +++ b/src/app/browser/window/tab/item/identity/gemini.rs @@ -48,7 +48,7 @@ impl Gemini { .make(None, &widget.form.name.value().unwrap()) { Ok(profile_identity_gemini_id) => profile_identity_gemini_id, - Err(reason) => todo!("{}", reason.to_string()), + Err(e) => todo!("{}", e.to_string()), }, ), Value::ImportPem => Some( @@ -58,7 +58,7 @@ impl Gemini { .add(&widget.form.file.pem.take().unwrap()) { Ok(profile_identity_gemini_id) => profile_identity_gemini_id, - Err(reason) => todo!("{}", reason.to_string()), + Err(e) => todo!("{}", e.to_string()), }, ), }; @@ -67,19 +67,19 @@ impl Gemini { match option { // Activate identity for `auth_uri` Some(profile_identity_gemini_id) => { - if let Err(reason) = profile + if let Err(e) = profile .identity .gemini .auth .apply(profile_identity_gemini_id, &auth_url) { - todo!("{}", reason.to_string()) + todo!("{}", e.to_string()) }; } // Remove all identity auths for `auth_uri` None => { - if let Err(reason) = profile.identity.gemini.auth.remove_scope(&auth_url) { - todo!("{}", reason.to_string()) + if let Err(e) = profile.identity.gemini.auth.remove_scope(&auth_url) { + todo!("{}", e.to_string()) }; } } diff --git a/src/app/browser/window/tab/item/identity/gemini/widget/form/file.rs b/src/app/browser/window/tab/item/identity/gemini/widget/form/file.rs index 095f78cf..ed27fb52 100644 --- a/src/app/browser/window/tab/item/identity/gemini/widget/form/file.rs +++ b/src/app/browser/window/tab/item/identity/gemini/widget/form/file.rs @@ -75,17 +75,17 @@ impl File { button.set_css_classes(&["success"]); button.set_label(filename) } - Err(reason) => { + Err(e) => { button.set_css_classes(&["error"]); - button.set_label(reason.message()) + button.set_label(e.message()) } } } None => todo!(), }, - Err(reason) => { + Err(e) => { button.set_css_classes(&["warning"]); - button.set_label(reason.message()) + button.set_label(e.message()) } } button.set_sensitive(true); // unlock diff --git a/src/app/browser/window/tab/item/identity/gemini/widget/form/save/certificate.rs b/src/app/browser/window/tab/item/identity/gemini/widget/form/save/certificate.rs index 788ff100..5621e0df 100644 --- a/src/app/browser/window/tab/item/identity/gemini/widget/form/save/certificate.rs +++ b/src/app/browser/window/tab/item/identity/gemini/widget/form/save/certificate.rs @@ -28,11 +28,11 @@ impl Certificate { data: identity.pem, name: certificate.subject_name().unwrap().replace("CN=", ""), }), - Err(reason) => Err(Error::TlsCertificate(reason)), + Err(e) => Err(Error::TlsCertificate(e)), }, None => Err(Error::NotFound(profile_identity_gemini_id)), }, - Err(reason) => Err(Error::Database(reason)), + Err(e) => Err(Error::Database(e)), } } } diff --git a/src/profile.rs b/src/profile.rs index c53ab5ea..6405a965 100644 --- a/src/profile.rs +++ b/src/profile.rs @@ -46,8 +46,8 @@ impl Profile { env!("CARGO_PKG_VERSION_MINOR") )); // @TODO remove after auto-migrate feature implementation - if let Err(reason) = create_dir_all(&config_path) { - panic!("{reason}") + if let Err(e) = create_dir_all(&config_path) { + panic!("{e}") } // Init database path @@ -57,7 +57,7 @@ impl Profile { // Init database connection let connection = match Connection::open(database_path.as_path()) { Ok(connection) => Rc::new(RwLock::new(connection)), - Err(reason) => panic!("{reason}"), + Err(e) => panic!("{e}"), }; // Init profile components @@ -65,24 +65,24 @@ impl Profile { // Init writable connection let mut connection = match connection.write() { Ok(connection) => connection, - Err(reason) => todo!("{reason}"), + Err(e) => todo!("{e}"), }; // Init new transaction let transaction = match connection.transaction() { Ok(transaction) => transaction, - Err(reason) => todo!("{reason}"), + Err(e) => todo!("{e}"), }; // Begin migration match migrate(&transaction) { Ok(_) => { // Confirm changes - if let Err(reason) = transaction.commit() { - todo!("{reason}") + if let Err(e) = transaction.commit() { + todo!("{e}") } } - Err(reason) => todo!("{reason}"), + Err(e) => todo!("{e}"), } } // unlock database @@ -94,7 +94,7 @@ impl Profile { Some(profile) => profile.id, None => match database.add(true, DateTime::now_local().unwrap(), None) { Ok(id) => id, - Err(reason) => todo!("{:?}", reason), + Err(e) => todo!("{:?}", e), }, }); @@ -104,7 +104,7 @@ impl Profile { // Init identity component let identity = Rc::new(match Identity::new(connection, profile_id) { Ok(result) => result, - Err(reason) => todo!("{:?}", reason.to_string()), + Err(e) => todo!("{:?}", e.to_string()), }); // Result @@ -119,8 +119,8 @@ impl Profile { pub fn migrate(tx: &Transaction) -> Result<(), String> { // Migrate self components - if let Err(reason) = database::init(tx) { - return Err(reason.to_string()); + if let Err(e) = database::init(tx) { + return Err(e.to_string()); } // Delegate migration to children components diff --git a/src/profile/bookmark.rs b/src/profile/bookmark.rs index e67ddc58..20f64e7b 100644 --- a/src/profile/bookmark.rs +++ b/src/profile/bookmark.rs @@ -28,12 +28,12 @@ impl Bookmark { match database.records(None) { Ok(records) => { for record in records { - if let Err(reason) = memory.add(record.request, record.id) { - todo!("{}", reason.to_string()) + if let Err(e) = memory.add(record.request, record.id) { + todo!("{}", e.to_string()) } } } - Err(reason) => todo!("{}", reason.to_string()), + Err(e) => todo!("{}", e.to_string()), } // Return new `Self` diff --git a/src/profile/bookmark/database.rs b/src/profile/bookmark/database.rs index ac52b598..f91e2900 100644 --- a/src/profile/bookmark/database.rs +++ b/src/profile/bookmark/database.rs @@ -52,7 +52,7 @@ impl Database { // Done match tx.commit() { Ok(_) => Ok(id), - Err(reason) => Err(reason), + Err(e) => Err(e), } } @@ -66,9 +66,9 @@ impl Database { match delete(&tx, id) { Ok(_) => match tx.commit() { Ok(_) => Ok(()), - Err(reason) => Err(reason), + Err(e) => Err(e), }, - Err(reason) => Err(reason), + Err(e) => Err(e), } } } diff --git a/src/profile/identity.rs b/src/profile/identity.rs index 0422b27a..cbfcfb45 100644 --- a/src/profile/identity.rs +++ b/src/profile/identity.rs @@ -29,16 +29,16 @@ impl Identity { Some(identity) => identity.id, None => match database.add(profile_id, true) { Ok(id) => id, - Err(reason) => return Err(Error::Database(reason)), + Err(e) => return Err(Error::Database(e)), }, }, - Err(reason) => return Err(Error::Database(reason)), + Err(e) => return Err(Error::Database(e)), }); // Init gemini component let gemini = Rc::new(match Gemini::new(connection, profile_identity_id) { Ok(result) => result, - Err(reason) => return Err(Error::Gemini(reason)), + Err(e) => return Err(Error::Gemini(e)), }); // Done @@ -53,8 +53,8 @@ impl Identity { pub fn migrate(tx: &Transaction) -> Result<(), String> { // Migrate self components - if let Err(reason) = database::init(tx) { - return Err(reason.to_string()); + if let Err(e) = database::init(tx) { + return Err(e.to_string()); } // Delegate migration to childs diff --git a/src/profile/identity/database.rs b/src/profile/identity/database.rs index a9b95220..fc522505 100644 --- a/src/profile/identity/database.rs +++ b/src/profile/identity/database.rs @@ -59,7 +59,7 @@ impl Database { // Done match tx.commit() { Ok(_) => Ok(id), - Err(reason) => Err(reason), + Err(e) => Err(e), } } } diff --git a/src/profile/identity/error.rs b/src/profile/identity/error.rs index 6e49458e..4a183c65 100644 --- a/src/profile/identity/error.rs +++ b/src/profile/identity/error.rs @@ -9,11 +9,11 @@ pub enum Error { impl Display for Error { fn fmt(&self, f: &mut Formatter) -> Result { match self { - Self::Database(reason) => { - write!(f, "Database error: {reason}") + Self::Database(e) => { + write!(f, "Database error: {e}") } - Self::Gemini(reason) => { - write!(f, "Could not init Gemini identity: {reason}") + Self::Gemini(e) => { + write!(f, "Could not init Gemini identity: {e}") } } } diff --git a/src/profile/identity/gemini.rs b/src/profile/identity/gemini.rs index 2285144d..b10cc417 100644 --- a/src/profile/identity/gemini.rs +++ b/src/profile/identity/gemini.rs @@ -36,7 +36,7 @@ impl Gemini { // Init components let auth = match Auth::new(connection.clone()) { Ok(auth) => Rc::new(auth), - Err(reason) => return Err(Error::Auth(reason)), + Err(e) => return Err(Error::Auth(e)), }; let database = Rc::new(Database::new(connection, profile_identity_id.clone())); let memory = Rc::new(Memory::new()); @@ -64,7 +64,7 @@ impl Gemini { self.index()?; Ok(profile_identity_gemini_id) } - Err(reason) => Err(Error::Database(reason)), + Err(e) => Err(Error::Database(e)), } } @@ -76,7 +76,7 @@ impl Gemini { self.index()?; Ok(()) } - Err(reason) => Err(Error::Database(reason)), + Err(e) => Err(Error::Database(e)), }, Err(e) => Err(Error::Auth(e)), } @@ -97,27 +97,27 @@ impl Gemini { name, ) { Ok(pem) => self.add(&pem), - Err(reason) => Err(Error::Certificate(reason)), + Err(e) => Err(Error::Certificate(e)), } } /// Create new `Memory` index from `Database` for `Self` pub fn index(&self) -> Result<(), Error> { // Clear previous records - if let Err(reason) = self.memory.clear() { - return Err(Error::Memory(reason)); + if let Err(e) = self.memory.clear() { + return Err(Error::Memory(e)); } // Build new index match self.database.records() { Ok(records) => { for record in records { - if let Err(reason) = self.memory.add(record.id, record.pem) { - return Err(Error::Memory(reason)); + if let Err(e) = self.memory.add(record.id, record.pem) { + return Err(Error::Memory(e)); } } } - Err(reason) => return Err(Error::Database(reason)), + Err(e) => return Err(Error::Database(e)), }; Ok(()) @@ -135,7 +135,7 @@ impl Gemini { pem, }); } - Err(reason) => todo!("{:?}", reason.to_string()), + Err(e) => todo!("{:?}", e.to_string()), } } None diff --git a/src/profile/identity/gemini/auth.rs b/src/profile/identity/gemini/auth.rs index 07b8ad89..26ecd2cd 100644 --- a/src/profile/identity/gemini/auth.rs +++ b/src/profile/identity/gemini/auth.rs @@ -49,7 +49,7 @@ impl Auth { let profile_identity_gemini_auth_id = match self.database.add(profile_identity_gemini_id, scope) { Ok(id) => id, - Err(reason) => return Err(Error::Database(reason)), + Err(e) => return Err(Error::Database(e)), }; // Reindex @@ -64,12 +64,12 @@ impl Auth { match self.database.records_scope(Some(scope)) { Ok(records) => { for record in records { - if let Err(reason) = self.database.delete(record.id) { - return Err(Error::Database(reason)); + if let Err(e) = self.database.delete(record.id) { + return Err(Error::Database(e)); } } } - Err(reason) => return Err(Error::Database(reason)), + Err(e) => return Err(Error::Database(e)), } self.index()?; Ok(()) @@ -80,12 +80,12 @@ impl Auth { match self.database.records_ref(profile_identity_gemini_id) { Ok(records) => { for record in records { - if let Err(reason) = self.database.delete(record.id) { - return Err(Error::Database(reason)); + if let Err(e) = self.database.delete(record.id) { + return Err(Error::Database(e)); } } } - Err(reason) => return Err(Error::Database(reason)), + Err(e) => return Err(Error::Database(e)), } self.index()?; Ok(()) @@ -94,23 +94,23 @@ impl Auth { /// Create new `Memory` index from `Database` for `Self` pub fn index(&self) -> Result<(), Error> { // Clear previous records - if let Err(reason) = self.memory.clear() { - return Err(Error::Memory(reason)); + if let Err(e) = self.memory.clear() { + return Err(Error::Memory(e)); } // Build new index match self.database.records_scope(None) { Ok(records) => { for record in records { - if let Err(reason) = self + if let Err(e) = self .memory .add(record.scope, record.profile_identity_gemini_id) { - return Err(Error::Memory(reason)); + return Err(Error::Memory(e)); } } } - Err(reason) => return Err(Error::Database(reason)), + Err(e) => return Err(Error::Database(e)), } Ok(()) diff --git a/src/profile/identity/gemini/auth/database.rs b/src/profile/identity/gemini/auth/database.rs index aa634eb0..e0708226 100644 --- a/src/profile/identity/gemini/auth/database.rs +++ b/src/profile/identity/gemini/auth/database.rs @@ -37,7 +37,7 @@ impl Database { // Done match tx.commit() { Ok(_) => Ok(id), - Err(reason) => Err(reason), + Err(e) => Err(e), } } @@ -53,7 +53,7 @@ impl Database { // Done match tx.commit() { Ok(_) => Ok(()), - Err(reason) => Err(reason), + Err(e) => Err(e), } } diff --git a/src/profile/identity/gemini/auth/error.rs b/src/profile/identity/gemini/auth/error.rs index eb878428..31c2bcbf 100644 --- a/src/profile/identity/gemini/auth/error.rs +++ b/src/profile/identity/gemini/auth/error.rs @@ -9,8 +9,8 @@ pub enum Error { impl Display for Error { fn fmt(&self, f: &mut Formatter) -> Result { match self { - Self::Database(reason) => write!(f, "Database error: {reason}"), - Self::Memory(reason) => write!(f, "Memory error: {reason}"), + Self::Database(e) => write!(f, "Database error: {e}"), + Self::Memory(e) => write!(f, "Memory error: {e}"), } } } diff --git a/src/profile/identity/gemini/database.rs b/src/profile/identity/gemini/database.rs index 7e06be12..ba251a6c 100644 --- a/src/profile/identity/gemini/database.rs +++ b/src/profile/identity/gemini/database.rs @@ -41,7 +41,7 @@ impl Database { // Done match tx.commit() { Ok(_) => Ok(id), - Err(reason) => Err(reason), + Err(e) => Err(e), } } @@ -57,7 +57,7 @@ impl Database { // Done match tx.commit() { Ok(_) => Ok(()), - Err(reason) => Err(reason), + Err(e) => Err(e), } } diff --git a/src/profile/identity/gemini/identity.rs b/src/profile/identity/gemini/identity.rs index cc704789..ec34fb29 100644 --- a/src/profile/identity/gemini/identity.rs +++ b/src/profile/identity/gemini/identity.rs @@ -15,7 +15,7 @@ impl Identity { pub fn to_tls_certificate(&self) -> Result { match TlsCertificate::from_pem(&self.pem) { Ok(certificate) => Ok(certificate), - Err(reason) => Err(Error::TlsCertificate(reason)), + Err(e) => Err(Error::TlsCertificate(e)), } } }