xmpp: update to edition 2024

pep created

Signed-off-by: pep <pep@bouah.net>

Change summary

xmpp/Cargo.toml                        |  2 +-
xmpp/ChangeLog                         |  1 +
xmpp/examples/hello_bot.rs             |  6 ++++--
xmpp/src/agent.rs                      |  6 +++---
xmpp/src/builder.rs                    |  4 ++--
xmpp/src/delay.rs                      |  8 ++++----
xmpp/src/event.rs                      |  2 +-
xmpp/src/event_loop.rs                 |  4 ++--
xmpp/src/iq/result.rs                  |  4 ++--
xmpp/src/message/receive/chat.rs       |  6 ++++--
xmpp/src/message/receive/group_chat.rs |  2 +-
xmpp/src/message/receive/mod.rs        |  2 +-
xmpp/src/muc/private_message.rs        |  2 +-
xmpp/src/muc/room.rs                   |  2 +-
xmpp/src/presence/receive.rs           | 10 ++++++++--
xmpp/src/presence/send.rs              |  2 +-
xmpp/src/pubsub/avatar.rs              |  2 +-
xmpp/src/pubsub/mod.rs                 |  2 +-
xmpp/src/upload/receive.rs             |  2 +-
19 files changed, 40 insertions(+), 29 deletions(-)

Detailed changes

xmpp/Cargo.toml 🔗

@@ -11,7 +11,7 @@ repository = "https://gitlab.com/xmpp-rs/xmpp-rs"
 keywords = ["xmpp", "jabber", "chat", "messaging", "bot"]
 categories = ["network-programming"]
 license = "MPL-2.0"
-edition = "2021"
+edition = "2024"
 
 [dependencies]
 chrono = "0.4"

xmpp/ChangeLog 🔗

@@ -42,6 +42,7 @@ XXXX-YY-ZZ [ RELEASER <admin@localhost> ]
         is meant to stay behind a feature. Also allows directly receiving
         stanzas.
       - Added documentation on `Event` enum.
+      - Update to edition 2024
     * Fixes:
       - Use tokio::sync::RwLock not std::sync::RwLock (!432)
       - The default caps node has been shortened to https://xmpp.rs since we

xmpp/examples/hello_bot.rs 🔗

@@ -7,9 +7,9 @@
 #[cfg(feature = "rustls-any-backend")]
 use xmpp::tokio_xmpp::rustls;
 use xmpp::{
+    Agent, ClientBuilder, ClientFeature, ClientType, Event, RoomNick,
     jid::BareJid,
     muc::room::{JoinRoomSettings, RoomMessageSettings},
-    Agent, ClientBuilder, ClientFeature, ClientType, Event, RoomNick,
 };
 
 use tokio::signal::ctrl_c;
@@ -21,7 +21,9 @@ use std::str::FromStr;
     feature = "rustls-any-backend",
     not(any(feature = "aws_lc_rs", feature = "ring"))
 ))]
-compile_error!("using rustls (e.g. via the ktls feature) needs an enabled rustls backend feature (either aws_lc_rs or ring).");
+compile_error!(
+    "using rustls (e.g. via the ktls feature) needs an enabled rustls backend feature (either aws_lc_rs or ring)."
+);
 
 #[tokio::main]
 async fn main() -> Result<(), Option<()>> {

xmpp/src/agent.rs 🔗

@@ -12,15 +12,15 @@ use tokio::io;
 use tokio::sync::RwLock;
 
 use crate::{
-    event_loop,
+    Error, Event, RoomNick, event_loop,
     jid::{BareJid, Jid},
     message, muc,
     parsers::disco::DiscoInfoResult,
-    upload, Error, Event, RoomNick,
+    upload,
 };
 use tokio_xmpp::Client as TokioXmppClient;
 #[cfg(feature = "escape-hatch")]
-use tokio_xmpp::{stanzastream::StanzaToken, Stanza};
+use tokio_xmpp::{Stanza, stanzastream::StanzaToken};
 
 pub struct Agent {
     pub(crate) client: TokioXmppClient,

xmpp/src/builder.rs 🔗

@@ -9,13 +9,13 @@ use crate::tokio_xmpp::connect::{DnsConfig, StartTlsServerConnector};
 use core::str::FromStr;
 
 use crate::{
+    Agent, ClientFeature, RoomNick,
     jid::{BareJid, Jid, ResourceRef},
     parsers::{
         disco::{DiscoInfoResult, Feature, Identity},
         ns,
     },
-    tokio_xmpp::{connect::ServerConnector, xmlstream::Timeouts, Client as TokioXmppClient},
-    Agent, ClientFeature, RoomNick,
+    tokio_xmpp::{Client as TokioXmppClient, connect::ServerConnector, xmlstream::Timeouts},
 };
 
 #[derive(Debug)]

xmpp/src/delay.rs 🔗

@@ -49,10 +49,10 @@ pub fn message_time_info(message: &Message) -> StanzaTimeInfo {
             match Delay::try_from(payload.clone()) {
                 Ok(delay) => delays.push(delay),
                 Err(e) => {
-                    error!("Wrong <delay> format in payload from {}:{}\n{:?}\nUsing received time only.",
-                    message.from.as_ref().unwrap().to_owned(),
-                    e,
-                    payload);
+                    error!(
+                        "Wrong <delay> format in payload from {}:{e}\n{payload:?}\nUsing received time only.",
+                        message.from.as_ref().unwrap().to_owned()
+                    );
                 }
             }
         }

xmpp/src/event.rs 🔗

@@ -12,7 +12,7 @@ use tokio_xmpp::parsers::roster::Item as RosterItem;
 use tokio_xmpp::parsers::{iq::Iq, message::Message, presence::Presence};
 
 use crate::parsers::confirm::Confirm;
-use crate::{delay::StanzaTimeInfo, Error, MessageId, RoomNick};
+use crate::{Error, MessageId, RoomNick, delay::StanzaTimeInfo};
 
 /// An Event notifying the client something has happened that may require attention.
 ///

xmpp/src/event_loop.rs 🔗

@@ -6,11 +6,11 @@
 
 use futures::StreamExt;
 use tokio_xmpp::{
-    parsers::{disco::DiscoInfoQuery, iq::Iq, roster::Roster},
     Event as TokioXmppEvent, Stanza,
+    parsers::{disco::DiscoInfoQuery, iq::Iq, roster::Roster},
 };
 
-use crate::{iq, message, presence, Agent, Event};
+use crate::{Agent, Event, iq, message, presence};
 
 /// Wait for new events, or Error::Disconnected when stream is closed and will not reconnect.
 pub async fn wait_for_events(agent: &mut Agent) -> Vec<Event> {

xmpp/src/iq/result.rs 🔗

@@ -5,12 +5,12 @@
 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 use crate::{
-    disco,
+    Agent, Event, RoomNick, disco,
     jid::Jid,
     minidom::Element,
     muc::room::JoinRoomSettings,
     parsers::{disco::DiscoInfoResult, ns, private::Query as PrivateXMLQuery, roster::Roster},
-    pubsub, upload, Agent, Event, RoomNick,
+    pubsub, upload,
 };
 
 pub async fn handle_iq_result(

xmpp/src/message/receive/chat.rs 🔗

@@ -9,7 +9,7 @@ use tokio_xmpp::{
     parsers::{confirm::Confirm, message::Message, message_correct::Replace, muc::user::MucUser},
 };
 
-use crate::{delay::StanzaTimeInfo, Agent, Event, RoomNick};
+use crate::{Agent, Event, RoomNick, delay::StanzaTimeInfo};
 
 pub async fn handle_message_chat(
     agent: &mut Agent,
@@ -43,7 +43,9 @@ pub async fn handle_message_chat(
 
     if is_muc_pm {
         if from.resource().is_none() {
-            warn!("Received malformed MessageType::Chat in muc#user namespace from a bare JID:\n{:#?}", message);
+            warn!(
+                "Received malformed MessageType::Chat in muc#user namespace from a bare JID:\n{message:#?}"
+            );
         } else {
             let full_from = from.clone().try_into_full().unwrap();
 

xmpp/src/message/receive/group_chat.rs 🔗

@@ -5,10 +5,10 @@
 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 use crate::{
+    Agent, Event, RoomNick,
     delay::StanzaTimeInfo,
     jid::Jid,
     parsers::{message::Message, message_correct::Replace},
-    Agent, Event, RoomNick,
 };
 
 pub async fn handle_message_group_chat(

xmpp/src/message/receive/mod.rs 🔗

@@ -9,7 +9,7 @@ use tokio_xmpp::parsers::{
     ns,
 };
 
-use crate::{delay::message_time_info, pubsub, Agent, Event};
+use crate::{Agent, Event, delay::message_time_info, pubsub};
 
 pub mod chat;
 pub mod group_chat;

xmpp/src/muc/private_message.rs 🔗

@@ -5,10 +5,10 @@
 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 use crate::{
+    Agent, RoomNick,
     jid::{BareJid, Jid},
     message::send::RawMessageSettings,
     parsers::{message::MessageType, muc::user::MucUser},
-    Agent, RoomNick,
 };
 
 #[derive(Clone, Debug)]

xmpp/src/muc/room.rs 🔗

@@ -5,6 +5,7 @@
 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 use crate::{
+    Agent, RoomNick,
     jid::{BareJid, ResourceRef},
     message::send::RawMessageSettings,
     parsers::{
@@ -12,7 +13,6 @@ use crate::{
         muc::Muc,
         presence::{Presence, Type as PresenceType},
     },
-    Agent, RoomNick,
 };
 
 #[derive(Clone, Debug)]

xmpp/src/presence/receive.rs 🔗

@@ -38,7 +38,10 @@ pub async fn handle_presence(agent: &mut Agent, presence: Presence) -> Vec<Event
                         agent.rooms_joined.insert(from.clone(), nick.clone());
                         agent.rooms_joining.remove(&from);
                     } else {
-                        warn!("Received self-presence from {} while the room was not marked as joining.", presence.from.unwrap());
+                        warn!(
+                            "Received self-presence from {} while the room was not marked as joining.",
+                            presence.from.unwrap()
+                        );
                     }
                     events.push(Event::RoomJoined(from.clone()));
                 }
@@ -48,7 +51,10 @@ pub async fn handle_presence(agent: &mut Agent, presence: Presence) -> Vec<Event
                         agent.rooms_joined.remove(&from);
                         agent.rooms_leaving.remove(&from);
                     } else {
-                        warn!("Received self-presence unavailable from {} while the room was not marked as leaving.", presence.from.unwrap());
+                        warn!(
+                            "Received self-presence unavailable from {} while the room was not marked as leaving.",
+                            presence.from.unwrap()
+                        );
                     }
                     events.push(Event::RoomLeft(from.clone()));
                 }

xmpp/src/presence/send.rs 🔗

@@ -5,7 +5,7 @@
 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 use tokio_xmpp::parsers::{
-    caps::{compute_disco, hash_caps, Caps},
+    caps::{Caps, compute_disco, hash_caps},
     disco::DiscoInfoResult,
     hashes::Algo,
     presence::{Presence, Type as PresenceType},

xmpp/src/pubsub/avatar.rs 🔗

@@ -14,9 +14,9 @@ use tokio_xmpp::parsers::{
     jid::Jid,
     ns,
     pubsub::{
+        NodeName,
         event::Item,
         pubsub::{Items, PubSub},
-        NodeName,
     },
 };
 

xmpp/src/pubsub/mod.rs 🔗

@@ -5,6 +5,7 @@
 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 use crate::{
+    Agent, Event, RoomNick,
     jid::{BareJid, Jid},
     minidom::Element,
     muc::room::{JoinRoomSettings, LeaveRoomSettings},
@@ -12,7 +13,6 @@ use crate::{
         bookmarks2, ns,
         pubsub::{self, pubsub::PubSub},
     },
-    Agent, Event, RoomNick,
 };
 
 use std::str::FromStr;

xmpp/src/upload/receive.rs 🔗

@@ -5,7 +5,7 @@
 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 use reqwest::{
-    header::HeaderMap as ReqwestHeaderMap, Body as ReqwestBody, Client as ReqwestClient,
+    Body as ReqwestBody, Client as ReqwestClient, header::HeaderMap as ReqwestHeaderMap,
 };
 use std::path::PathBuf;
 use tokio::fs::File;