From 3225c1c7d1b9d1c85bcd64bbbb51b35ecfc171de 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 48d39cf3..c718efdd 100644 --- a/xmpp/src/agent.rs +++ b/xmpp/src/agent.rs @@ -28,6 +28,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 73ceaab9..44c2d771 100644 --- a/xmpp/src/builder.rs +++ b/xmpp/src/builder.rs @@ -156,14 +156,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) } }