diff options
Diffstat (limited to '')
-rw-r--r-- | src/client/mod.rs | 17 |
1 files changed, 8 insertions, 9 deletions
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<encrypted::JabberClient<'j>> { 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) } } } |