diff options
Diffstat (limited to 'jabber/src/client.rs')
-rw-r--r-- | jabber/src/client.rs | 24 |
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), |