From a1d92635f65d60c33171ddcd88101427b1642d56 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Fri, 30 Aug 2024 11:05:40 +0200 Subject: [PATCH] Import std::io directly --- src/config.rs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/config.rs b/src/config.rs index 735cad7..13de77d 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,3 +1,5 @@ +#[cfg(feature = "rustls-native-certs")] +use std::io; #[cfg(feature = "rustls-platform-verifier")] use std::sync::Arc; @@ -30,9 +32,7 @@ pub trait ConfigBuilderExt { /// This will return an error if no valid certs were found. In that case, /// it's recommended to use `with_webpki_roots`. #[cfg(feature = "rustls-native-certs")] - fn with_native_roots( - self, - ) -> Result, std::io::Error>; + fn with_native_roots(self) -> Result, io::Error>; /// This configures the webpki roots, which are Mozilla's set of /// trusted roots as packaged by webpki-roots. @@ -51,9 +51,7 @@ impl ConfigBuilderExt for ConfigBuilder { #[cfg(feature = "rustls-native-certs")] #[cfg_attr(not(feature = "logging"), allow(unused_variables))] - fn with_native_roots( - self, - ) -> Result, std::io::Error> { + fn with_native_roots(self) -> Result, io::Error> { let mut roots = rustls::RootCertStore::empty(); let mut valid_count = 0; let mut invalid_count = 0; @@ -64,8 +62,8 @@ impl ConfigBuilderExt for ConfigBuilder { } if certs.is_empty() { - return Err(std::io::Error::new( - std::io::ErrorKind::NotFound, + return Err(io::Error::new( + io::ErrorKind::NotFound, format!("no native root CA certificates found (errors: {errors:?})"), )); } @@ -87,8 +85,8 @@ impl ConfigBuilderExt for ConfigBuilder { ); if roots.is_empty() { crate::log::debug!("no valid native root CA certificates found"); - Err(std::io::Error::new( - std::io::ErrorKind::NotFound, + Err(io::Error::new( + io::ErrorKind::NotFound, format!("no valid native root CA certificates found ({invalid_count} invalid)"), ))? }