From 320ef0781e06df9081785d1c56f6982f071cf109 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Mon, 1 Jan 2024 15:23:32 +0100 Subject: [PATCH] xmpp: Add Agent::new MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For ease of use in coming changes Signed-off-by: Maxime “pep” Buquet --- xmpp/src/agent.rs | 18 ++++++++++++++++++ xmpp/src/builder.rs | 10 +--------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/xmpp/src/agent.rs b/xmpp/src/agent.rs index df31db7a..7630a649 100644 --- a/xmpp/src/agent.rs +++ b/xmpp/src/agent.rs @@ -24,6 +24,24 @@ pub struct Agent { } impl Agent { + async fn new( + client: TokioXmppClient, + default_nick: String, + lang: String, + diso: DiscoInfoResult, + node: String, + ) -> Agent { + Agent { + client, + default_nick: Arc::new(RwLock::new(default_nick)), + lang: Arc::new(lang), + disco, + node, + uploads: Vec::new(), + awaiting_disco_bookmarks_type: false, + } + } + pub async fn disconnect(&mut self) -> Result<(), Error> { self.client.send_end().await } diff --git a/xmpp/src/builder.rs b/xmpp/src/builder.rs index d416a127..9c996b00 100644 --- a/xmpp/src/builder.rs +++ b/xmpp/src/builder.rs @@ -155,14 +155,6 @@ impl ClientBuilder<'_, C> { let disco = self.make_disco(); let node = self.website; - Agent { - client, - default_nick: Arc::new(RwLock::new(self.default_nick)), - lang: Arc::new(self.lang), - disco, - node, - uploads: Vec::new(), - awaiting_disco_bookmarks_type: false, - } + Agent::new(client, default_nick, lang, disco, node) } }