From 595d165479b8b12e456f39205d8433b822b07487 Mon Sep 17 00:00:00 2001 From: cel 🌸 Date: Fri, 6 Dec 2024 06:31:20 +0000 Subject: implement sink and stream properly UNFOLD UNFOLD --- jabber/src/client.rs | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) (limited to 'jabber/src/client.rs') 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> { + 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; - - fn poll_next( - self: std::pin::Pin<&mut Self>, - cx: &mut std::task::Context<'_>, - ) -> std::task::Poll> { - 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), -- cgit