From 39df1601d8dc77fb7a436d309327722109f36a33 Mon Sep 17 00:00:00 2001 From: Rodolphe Breard Date: Wed, 11 Mar 2020 21:18:48 +0100 Subject: [PATCH] Format code --- acme_common/src/crypto/openssl_certificate.rs | 2 +- acmed/build.rs | 4 ++-- acmed/src/acme_proto/http.rs | 6 +++--- acmed/src/certificate.rs | 2 +- acmed/src/config.rs | 3 ++- acmed/src/main_event_loop.rs | 2 +- 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/acme_common/src/crypto/openssl_certificate.rs b/acme_common/src/crypto/openssl_certificate.rs index 87a760d..24eaf23 100644 --- a/acme_common/src/crypto/openssl_certificate.rs +++ b/acme_common/src/crypto/openssl_certificate.rs @@ -72,7 +72,7 @@ impl X509Certificate { crt.tbs_certificate .validity .time_to_expiration() - .ok_or(Error::from("Invalid certificate validity.")) + .ok_or_else(|| Error::from("Invalid certificate validity.")) } pub fn subject_alt_names(&self) -> HashSet { diff --git a/acmed/build.rs b/acmed/build.rs index 745d83d..bd0b419 100644 --- a/acmed/build.rs +++ b/acmed/build.rs @@ -69,7 +69,7 @@ fn set_lock() { } fn get_openssl_version_unit(n: u64, pos: u32) -> u64 { - let p = 0xff_00_00_00_0 >> (8 * pos); + let p = 0x000f_f000_0000 >> (8 * pos); let n = n & p; n >> (8 * (3 - pos) + 4) } @@ -118,7 +118,7 @@ fn set_tls() { set_rustc_env_var!("ACMED_TLS_LIB_VERSION", version); set_rustc_env_var!("ACMED_TLS_LIB_NAME", "LibreSSL"); } - if let Ok(_) = env::var("CARGO_FEATURE_STANDALONE") { + if env::var("CARGO_FEATURE_STANDALONE").is_ok() { let version = get_lib_version("ring").unwrap(); set_rustc_env_var!("ACMED_TLS_LIB_VERSION", version); set_rustc_env_var!("ACMED_TLS_LIB_NAME", "ring"); diff --git a/acmed/src/acme_proto/http.rs b/acmed/src/acme_proto/http.rs index 4aa7ac7..ff19ead 100644 --- a/acmed/src/acme_proto/http.rs +++ b/acmed/src/acme_proto/http.rs @@ -100,7 +100,7 @@ fn nonce_from_response(cert: &Certificate, res: &Response) -> Result() }; - let rpos = res_body.rfind("}").unwrap_or(0); + let rpos = res_body.rfind('}').unwrap_or(0); let res_body = if rpos == 0 { res_body } else { diff --git a/acmed/src/certificate.rs b/acmed/src/certificate.rs index d5ca601..b871100 100644 --- a/acmed/src/certificate.rs +++ b/acmed/src/certificate.rs @@ -108,7 +108,7 @@ impl Certificate { self.debug(&format!("expires in {} days", expires_in.as_secs() / 86400)); // TODO: allow a custom duration (using time-parse ?) // 1814400 is 3 weeks (3 * 7 * 24 * 60 * 60) - let renewal_time = Duration::new(1814400, 0); + let renewal_time = Duration::new(1_814_400, 0); Ok(expires_in <= renewal_time) } diff --git a/acmed/src/config.rs b/acmed/src/config.rs index 8aba14f..b1b9846 100644 --- a/acmed/src/config.rs +++ b/acmed/src/config.rs @@ -300,7 +300,8 @@ impl Certificate { match &self.name { Some(n) => n.to_string(), None => self.domains.first().unwrap().dns.to_owned(), - }.replace("*", "_") + } + .replace("*", "_") } pub fn get_crt_name_format(&self) -> String { diff --git a/acmed/src/main_event_loop.rs b/acmed/src/main_event_loop.rs index db90fab..3ac39b7 100644 --- a/acmed/src/main_event_loop.rs +++ b/acmed/src/main_event_loop.rs @@ -74,7 +74,7 @@ impl MainEventLoop { Ok(MainEventLoop { certs, - root_certs: root_certs.iter().map(|v| v.to_string()).collect(), + root_certs: root_certs.iter().map(|v| (*v).to_string()).collect(), }) }