From 070529e1ac3374a495f7b194d88b90ba9ff8bbd0 Mon Sep 17 00:00:00 2001 From: Kyle Clemens Date: Sun, 13 May 2018 18:34:32 -0400 Subject: [PATCH] Add 'tls_enabled' method to Config. --- lib/src/config/config.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/src/config/config.rs b/lib/src/config/config.rs index 0af94a30..18b04b36 100644 --- a/lib/src/config/config.rs +++ b/lib/src/config/config.rs @@ -651,6 +651,17 @@ impl Config { self.extras.iter().map(|(k, v)| (k.as_str(), v)) } + /// Returns `true` if TLS is enabled. + /// + /// Always returns `false` if the `tls` compilation feature is not enabled. + pub fn tls_enabled(&self) -> bool { + if cfg!(feature = "tls") { + self.tls.is_some() + } else { + false + } + } + /// Retrieves the secret key from `self`. #[inline] pub(crate) fn secret_key(&self) -> &Key {