diff options
author | cel 🌸 <cel@blos.sm> | 2023-10-20 04:51:56 +0100 |
---|---|---|
committer | cel 🌸 <cel@blos.sm> | 2023-10-20 04:51:56 +0100 |
commit | ba94ee66fafbabd63d6d1ed5edf435d4c46c6796 (patch) | |
tree | fe1bebc35914941b5c4fbd6f0286f4c9f8916154 /src/client/mod.rs | |
parent | 2536fa4937f0283b4187142cc6cede8e1dbfafa8 (diff) | |
download | luz-ba94ee66fafbabd63d6d1ed5edf435d4c46c6796.tar.gz luz-ba94ee66fafbabd63d6d1ed5edf435d4c46c6796.tar.bz2 luz-ba94ee66fafbabd63d6d1ed5edf435d4c46c6796.zip |
WIP: refactor to parse incoming stream as state machine
Diffstat (limited to 'src/client/mod.rs')
-rw-r--r-- | src/client/mod.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/client/mod.rs b/src/client/mod.rs index 280e0a1..01df4a4 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -1,22 +1,24 @@ -pub mod encrypted; +// pub mod encrypted; pub mod unencrypted; // use async_trait::async_trait; -use crate::stanza::stream::StreamFeature; +// use crate::stanza::stream::StreamFeature; use crate::JabberError; use crate::Result; pub enum JabberClientType<'j> { - Encrypted(encrypted::JabberClient<'j>), + // Encrypted(encrypted::JabberClient<'j>), Unencrypted(unencrypted::JabberClient<'j>), } impl<'j> JabberClientType<'j> { + /// ensures an encrypted jabber client pub async fn ensure_tls(self) -> Result<encrypted::JabberClient<'j>> { match self { 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?) @@ -28,7 +30,7 @@ impl<'j> JabberClientType<'j> { } } -// TODO: jabber client trait over both client types +// TODO: jabber client trait over both client types using macro // #[async_trait] // pub trait JabberTrait { // async fn start_stream(&mut self) -> Result<()>; |