From e6a5d42aeb2af3be554d0f5d549260a4bce1da17 Mon Sep 17 00:00:00 2001 From: Matt Brubeck Date: Mon, 17 Mar 2025 16:21:55 -0700 Subject: [PATCH] rustfmt --- src/certificates.rs | 15 ++++++++++----- src/main.rs | 4 ++-- src/metadata.rs | 13 ++++++++++--- tests/tests.rs | 4 ++-- 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/certificates.rs b/src/certificates.rs index e0dc5b6..683f1eb 100644 --- a/src/certificates.rs +++ b/src/certificates.rs @@ -50,8 +50,13 @@ impl Display for CertLoadError { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { match self { Self::NoReadCertDir => write!(f, "Could not read from certificate directory."), - Self::Empty => write!(f, "No keys or certificates were found in the given directory.\nSpecify the --hostname option to generate these automatically."), - Self::BadKey(domain, err) => write!(f, "The key file for {domain} is malformed: {err:?}"), + Self::Empty => write!( + f, + "No keys or certificates were found in the given directory.\nSpecify the --hostname option to generate these automatically." + ), + Self::BadKey(domain, err) => { + write!(f, "The key file for {domain} is malformed: {err:?}") + } Self::MissingKey(domain) => write!(f, "The key file for {domain} is missing."), Self::MissingCert(domain) => { write!(f, "The certificate file for {domain} is missing.") @@ -134,13 +139,13 @@ impl CertStore { Err(CertLoadError::EmptyDomain(_)) => { /* there are no fallback keys */ } Err(CertLoadError::Empty) | Err(CertLoadError::NoReadCertDir) => unreachable!(), Err(CertLoadError::BadKey(_, e)) => { - return Err(CertLoadError::BadKey("fallback".to_string(), e)) + return Err(CertLoadError::BadKey("fallback".to_string(), e)); } Err(CertLoadError::MissingKey(_)) => { - return Err(CertLoadError::MissingKey("fallback".to_string())) + return Err(CertLoadError::MissingKey("fallback".to_string())); } Err(CertLoadError::MissingCert(_)) => { - return Err(CertLoadError::MissingCert("fallback".to_string())) + return Err(CertLoadError::MissingCert("fallback".to_string())); } // For the fallback keys there is no domain name to verify them // against, so we can skip that step and only have to do it for the diff --git a/src/main.rs b/src/main.rs index d6a1d0f..d40346c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,7 +7,7 @@ use codes::*; use metadata::{FileOptions, PresetMeta}; use { - percent_encoding::{percent_decode_str, percent_encode, AsciiSet, CONTROLS}, + percent_encoding::{AsciiSet, CONTROLS, percent_decode_str, percent_encode}, rcgen::{CertificateParams, DnType, KeyPair}, std::{ borrow::Cow, @@ -27,9 +27,9 @@ use { sync::Mutex, }, tokio_rustls::{ + TlsAcceptor, rustls::{server::ServerConfig, version::TLS13}, server::TlsStream, - TlsAcceptor, }, url::{Host, Url}, }; diff --git a/src/metadata.rs b/src/metadata.rs index cc98f12..8076d69 100644 --- a/src/metadata.rs +++ b/src/metadata.rs @@ -1,5 +1,5 @@ use configparser::ini::Ini; -use glob::{glob_with, MatchOptions}; +use glob::{MatchOptions, glob_with}; use std::collections::BTreeMap; use std::path::{Path, PathBuf}; use std::time::SystemTime; @@ -146,7 +146,10 @@ impl FileOptions { || !header.chars().nth(1).unwrap().is_ascii_digit() || !header.chars().nth(2).unwrap().is_whitespace() { - log::error!("Line for {:?} starts like a full header line, but it is incorrect; ignoring it.", path); + log::error!( + "Line for {:?} starts like a full header line, but it is incorrect; ignoring it.", + path + ); return; } let separator = header.chars().nth(2).unwrap(); @@ -154,7 +157,11 @@ impl FileOptions { // the Gemini specification says that the third // character has to be a space, so correct any // other whitespace to it (e.g. tabs) - log::warn!("Full Header line for {:?} has an invalid character, treating {:?} as a space.", path, separator); + log::warn!( + "Full Header line for {:?} has an invalid character, treating {:?} as a space.", + path, + separator + ); } let status = header .chars() diff --git a/tests/tests.rs b/tests/tests.rs index 1520240..6318cb9 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -13,7 +13,7 @@ //! You should have received a copy of the GNU General Public License //! along with this program. If not, see . -use rustls::{pki_types::CertificateDer, ClientConnection, RootCertStore}; +use rustls::{ClientConnection, RootCertStore, pki_types::CertificateDer}; use std::convert::TryInto; use std::io::{BufRead, BufReader, Read, Write}; use std::net::{SocketAddr, TcpStream, ToSocketAddrs}; @@ -530,7 +530,7 @@ mod vhosts { mod multicert { use super::*; - use rustls::{pki_types::CertificateDer, ClientConnection, RootCertStore}; + use rustls::{ClientConnection, RootCertStore, pki_types::CertificateDer}; use std::io::Write; use std::net::TcpStream;