From f43911ccbae3856b35b0d3e8ec6ac6450e295da6 Mon Sep 17 00:00:00 2001 From: cel 🌸 Date: Tue, 11 Jul 2023 21:28:42 +0100 Subject: remove serde functions --- src/client/mod.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src/client/mod.rs') diff --git a/src/client/mod.rs b/src/client/mod.rs index fe3dd34..d545923 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -15,17 +15,16 @@ pub enum JabberClientType<'j> { impl<'j> JabberClientType<'j> { pub async fn ensure_tls(self) -> Result> { match self { - Self::Encrypted(mut c) => { - c.start_stream(); - Ok(c) - } + Self::Encrypted(c) => Ok(c), Self::Unencrypted(mut c) => { - c.start_stream().await?; - let features = c.get_features().await?; - if features.contains(&StreamFeature::StartTls) { - Ok(c.starttls().await?) + if let Some(features) = c.get_features().await? { + if features.contains(&StreamFeature::StartTls) { + Ok(c.starttls().await?) + } else { + Err(JabberError::StartTlsUnavailable) + } } else { - Err(JabberError::StartTlsUnavailable) + Err(JabberError::NoFeatures) } } } -- cgit