From 16458dedf112d49401f5752aec069e760bc97727 Mon Sep 17 00:00:00 2001 From: Astro Date: Tue, 15 Oct 2019 21:18:24 +0200 Subject: [PATCH] client: replace jid field with bound_jid() resolves gitlab MR #8 --- src/client/mod.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/client/mod.rs b/src/client/mod.rs index 4f31dad0..fab4571c 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -22,8 +22,6 @@ use self::bind::ClientBind; /// XMPP client connection and state pub struct Client { - /// The client's current Jabber-Id - pub jid: Jid, state: ClientState, } @@ -51,9 +49,8 @@ impl Client { /// Start a new client given that the JID is already parsed. pub fn new_with_jid(jid: Jid, password: &str) -> Self { let password = password.to_owned(); - let connect = Self::make_connect(jid.clone(), password.clone()); + let connect = Self::make_connect(jid, password.clone()); let client = Client { - jid, state: ClientState::Connecting(Box::new(connect)), }; client @@ -125,6 +122,15 @@ impl Client { fn bind(stream: xmpp_stream::XMPPStream) -> ClientBind { ClientBind::new(stream) } + + /// Get the client's bound JID (the one reported by the XMPP + /// server). + pub fn bound_jid(&self) -> Option<&Jid> { + match self.state { + ClientState::Connected(ref stream) => Some(&stream.jid), + _ => None, + } + } } impl Stream for Client {