From 42a43f175e792b3cab71595a23ef586f459dce07 Mon Sep 17 00:00:00 2001 From: DarkCat09 Date: Fri, 30 Aug 2024 15:59:05 +0400 Subject: [PATCH] style/fix: cleanup ClientBuilder by removing Option from tls_versions --- src/client/builder.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/client/builder.rs b/src/client/builder.rs index 97daeb0..97f9430 100644 --- a/src/client/builder.rs +++ b/src/client/builder.rs @@ -18,7 +18,7 @@ use tokio_rustls::{ /// Builder for creating configured [`Client`] instance pub struct ClientBuilder { ss_verifier: Option>, - tls_versions: Option<&'static [&'static SupportedProtocolVersion]>, + tls_versions: &'static [&'static SupportedProtocolVersion], #[cfg(feature = "hickory")] dns: Option, } @@ -36,7 +36,7 @@ impl ClientBuilder { pub fn new() -> Self { ClientBuilder { ss_verifier: None, - tls_versions: None, + tls_versions: rustls::DEFAULT_VERSIONS, #[cfg(feature = "hickory")] dns: None, } @@ -49,11 +49,7 @@ impl ClientBuilder { .unwrap_or_else(|| Arc::new(rustls::crypto::ring::default_provider())); let tls_config = rustls::ClientConfig::builder_with_provider(provider.clone()) - .with_protocol_versions(if let Some(versions) = self.tls_versions { - versions - } else { - rustls::DEFAULT_VERSIONS - }) + .with_protocol_versions(self.tls_versions) .unwrap() .dangerous() .with_custom_certificate_verifier(Arc::new(InternalCertVerifier::from(provider))); @@ -75,7 +71,7 @@ impl ClientBuilder { mut self, versions: &'static [&'static SupportedProtocolVersion], ) -> Self { - self.tls_versions = Some(versions); + self.tls_versions = versions; self }