diff --git a/lib/src/client.rs b/lib/src/client.rs index c635746..2dd76a9 100644 --- a/lib/src/client.rs +++ b/lib/src/client.rs @@ -1,4 +1,4 @@ -use std::fs; +use std::{fmt::Write, fs}; use async_trait::async_trait; use rand::{thread_rng, Rng}; @@ -49,11 +49,11 @@ impl TimeSync { TimeSync::Future { last_time_checked: _, time_offset, - } => (time + time_offset), + } => time + time_offset, TimeSync::Past { last_time_checked: _, time_offset, - } => (time - time_offset), + } => time - time_offset, } } } @@ -108,10 +108,10 @@ impl AuthyClient { pub fn with_url(url: &str, device_name: &str, backup_password: &str) -> Result { let mut signature = [0u8; 32]; thread_rng().fill(&mut signature); - let signature = signature - .iter() - .map(|n| format!("{:x}", n)) - .collect::(); + let signature = signature.iter().fold(String::new(), |mut output, n| { + let _ = write!(output, "{:x}", n); + output + }); Ok(Self { url: url.parse()?, @@ -236,7 +236,7 @@ impl AuthyClientApi for AuthyClient { #[instrument] async fn complete_registration(&mut self, pin: &str) -> Result<()> { // I'm assuming this is used for idempotency so this should suffice - let uuid = format!("{:x}", md5::compute(&pin.as_bytes())); + let uuid = format!("{:x}", md5::compute(pin.as_bytes())); let payload = AuthyCompleteRegistrationRequest { api_key: API_KEY.to_string(), locale: DEFAULT_LOCALE.to_string(), diff --git a/lib/src/models.rs b/lib/src/models.rs index 4e9242a..8554451 100644 --- a/lib/src/models.rs +++ b/lib/src/models.rs @@ -40,7 +40,7 @@ pub enum CheckRegistrationStatus { impl Device { pub(crate) fn hash_secret(&self) -> String { - format!("{:x}", sha2::Sha256::digest(&self.secret_seed.as_bytes())) + format!("{:x}", sha2::Sha256::digest(self.secret_seed.as_bytes())) } } diff --git a/stub_server/src/lib.rs b/stub_server/src/lib.rs index 8a4d586..8d3b7b0 100644 --- a/stub_server/src/lib.rs +++ b/stub_server/src/lib.rs @@ -36,7 +36,7 @@ impl WiremockRunner { check_process( &compose() - .args(&["up", "-d"]) + .args(["up", "-d"]) .output() .await .wrap_err("error to bring wiremock up")?, @@ -44,7 +44,7 @@ impl WiremockRunner { let host = check_process( &compose() - .args(&["port", "wiremock", "8080"]) + .args(["port", "wiremock", "8080"]) .output() .await .wrap_err("failed to get wiremock port")?,