aboutsummaryrefslogtreecommitdiffstats
path: root/jabber/src/client.rs
diff options
context:
space:
mode:
authorLibravatar cel 🌸 <cel@bunny.garden>2024-12-06 06:31:20 +0000
committerLibravatar cel 🌸 <cel@bunny.garden>2024-12-06 06:31:20 +0000
commit595d165479b8b12e456f39205d8433b822b07487 (patch)
treea1a112f92c738ff7b22e97d9f71dda71fe85cf76 /jabber/src/client.rs
parentaaf34b5bcad1a897bb6fb704aab6b9cd6f6c4620 (diff)
downloadluz-595d165479b8b12e456f39205d8433b822b07487.tar.gz
luz-595d165479b8b12e456f39205d8433b822b07487.tar.bz2
luz-595d165479b8b12e456f39205d8433b822b07487.zip
implement sink and stream properly UNFOLD UNFOLD
Diffstat (limited to 'jabber/src/client.rs')
-rw-r--r--jabber/src/client.rs24
1 files changed, 8 insertions, 16 deletions
diff --git a/jabber/src/client.rs b/jabber/src/client.rs
index c8b0b73..c6cab07 100644
--- a/jabber/src/client.rs
+++ b/jabber/src/client.rs
@@ -56,6 +56,14 @@ impl JabberClient {
}
}
+ pub(crate) fn inner(self) -> Result<JabberStream<Tls>> {
+ match self.connection {
+ ConnectionState::Disconnected => return Err(Error::Disconnected),
+ ConnectionState::Connecting(_connecting) => return Err(Error::Connecting),
+ ConnectionState::Connected(jabber_stream) => return Ok(jabber_stream),
+ }
+ }
+
pub async fn send_stanza(&mut self, stanza: &Stanza) -> Result<()> {
match &mut self.connection {
ConnectionState::Disconnected => return Err(Error::Disconnected),
@@ -67,22 +75,6 @@ impl JabberClient {
}
}
-impl Stream for JabberClient {
- type Item = Result<Stanza>;
-
- fn poll_next(
- self: std::pin::Pin<&mut Self>,
- cx: &mut std::task::Context<'_>,
- ) -> std::task::Poll<Option<Self::Item>> {
- let mut client = pin!(self);
- match &mut client.connection {
- ConnectionState::Disconnected => Poll::Pending,
- ConnectionState::Connecting(_connecting) => Poll::Pending,
- ConnectionState::Connected(jabber_stream) => jabber_stream.poll_next_unpin(cx),
- }
- }
-}
-
pub enum ConnectionState {
Disconnected,
Connecting(Connecting),