From e9b226e1aedb1d8fd337b0850b893781127266c9 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Wed, 24 Jul 2024 20:39:27 +0200 Subject: [PATCH] tokio-xmpp: Import Jid, BareJid and Element properly xmpp-parsers has stopped reexporting them, instead it reexports only the crates themselves. --- tokio-xmpp/examples/contact_addr.rs | 3 ++- tokio-xmpp/examples/download_avatars.rs | 3 ++- tokio-xmpp/examples/echo_bot.rs | 3 ++- tokio-xmpp/examples/echo_component.rs | 3 ++- tokio-xmpp/examples/send_message.rs | 2 +- tokio-xmpp/src/client/async_client.rs | 3 ++- tokio-xmpp/src/client/connect.rs | 2 +- tokio-xmpp/src/client/simple_client.rs | 3 ++- tokio-xmpp/src/component/connect.rs | 2 +- tokio-xmpp/src/component/mod.rs | 3 ++- tokio-xmpp/src/connect.rs | 2 +- tokio-xmpp/src/error.rs | 2 +- tokio-xmpp/src/event.rs | 3 ++- tokio-xmpp/src/lib.rs | 4 ++-- tokio-xmpp/src/starttls/client.rs | 2 +- tokio-xmpp/src/starttls/mod.rs | 3 ++- tokio-xmpp/src/stream_features.rs | 3 ++- tokio-xmpp/src/stream_start.rs | 3 ++- tokio-xmpp/src/tcp/mod.rs | 2 +- tokio-xmpp/src/xmpp_codec.rs | 2 +- tokio-xmpp/src/xmpp_stream.rs | 3 ++- 21 files changed, 34 insertions(+), 22 deletions(-) diff --git a/tokio-xmpp/examples/contact_addr.rs b/tokio-xmpp/examples/contact_addr.rs index c5ff776d..1c10f292 100644 --- a/tokio-xmpp/examples/contact_addr.rs +++ b/tokio-xmpp/examples/contact_addr.rs @@ -1,4 +1,5 @@ use futures::stream::StreamExt; +use minidom::Element; use std::env::args; use std::process::exit; use std::str::FromStr; @@ -6,9 +7,9 @@ use tokio_xmpp::AsyncClient as Client; use xmpp_parsers::{ disco::{DiscoInfoQuery, DiscoInfoResult}, iq::{Iq, IqType}, + jid::{BareJid, Jid}, ns, server_info::ServerInfo, - BareJid, Element, Jid, }; #[tokio::main] diff --git a/tokio-xmpp/examples/download_avatars.rs b/tokio-xmpp/examples/download_avatars.rs index d8dbd67f..945ee56c 100644 --- a/tokio-xmpp/examples/download_avatars.rs +++ b/tokio-xmpp/examples/download_avatars.rs @@ -1,4 +1,5 @@ use futures::stream::StreamExt; +use minidom::Element; use std::env::args; use std::fs::{create_dir_all, File}; use std::io::{self, Write}; @@ -11,6 +12,7 @@ use xmpp_parsers::{ disco::{DiscoInfoQuery, DiscoInfoResult, Feature, Identity}, hashes::Algo, iq::{Iq, IqType}, + jid::{BareJid, Jid}, message::Message, ns, presence::{Presence, Type as PresenceType}, @@ -20,7 +22,6 @@ use xmpp_parsers::{ NodeName, }, stanza_error::{DefinedCondition, ErrorType, StanzaError}, - BareJid, Element, Jid, }; #[tokio::main] diff --git a/tokio-xmpp/examples/echo_bot.rs b/tokio-xmpp/examples/echo_bot.rs index 9be2173e..3dcf3693 100644 --- a/tokio-xmpp/examples/echo_bot.rs +++ b/tokio-xmpp/examples/echo_bot.rs @@ -1,11 +1,12 @@ use futures::stream::StreamExt; +use minidom::Element; use std::env::args; use std::process::exit; use std::str::FromStr; use tokio_xmpp::AsyncClient as Client; +use xmpp_parsers::jid::{BareJid, Jid}; use xmpp_parsers::message::{Body, Message, MessageType}; use xmpp_parsers::presence::{Presence, Show as PresenceShow, Type as PresenceType}; -use xmpp_parsers::{BareJid, Element, Jid}; #[tokio::main] async fn main() { diff --git a/tokio-xmpp/examples/echo_component.rs b/tokio-xmpp/examples/echo_component.rs index 98417dce..bfaf44be 100644 --- a/tokio-xmpp/examples/echo_component.rs +++ b/tokio-xmpp/examples/echo_component.rs @@ -1,11 +1,12 @@ use futures::stream::StreamExt; +use minidom::Element; use std::env::args; use std::process::exit; use std::str::FromStr; use tokio_xmpp::tcp::TcpComponent as Component; +use xmpp_parsers::jid::Jid; use xmpp_parsers::message::{Body, Message, MessageType}; use xmpp_parsers::presence::{Presence, Show as PresenceShow, Type as PresenceType}; -use xmpp_parsers::{Element, Jid}; #[tokio::main] async fn main() { diff --git a/tokio-xmpp/examples/send_message.rs b/tokio-xmpp/examples/send_message.rs index d929cd67..96f97ca6 100644 --- a/tokio-xmpp/examples/send_message.rs +++ b/tokio-xmpp/examples/send_message.rs @@ -3,8 +3,8 @@ use std::io::{stdin, Read}; use std::process::exit; use std::str::FromStr; use tokio_xmpp::SimpleClient as Client; +use xmpp_parsers::jid::Jid; use xmpp_parsers::message::{Body, Message}; -use xmpp_parsers::Jid; #[tokio::main] async fn main() { diff --git a/tokio-xmpp/src/client/async_client.rs b/tokio-xmpp/src/client/async_client.rs index 4cb52285..5c5b5fa2 100644 --- a/tokio-xmpp/src/client/async_client.rs +++ b/tokio-xmpp/src/client/async_client.rs @@ -1,9 +1,10 @@ use futures::{sink::SinkExt, task::Poll, Future, Sink, Stream}; +use minidom::Element; use std::mem::replace; use std::pin::Pin; use std::task::Context; use tokio::task::JoinHandle; -use xmpp_parsers::{ns, Element, Jid}; +use xmpp_parsers::{jid::Jid, ns}; use super::connect::client_login; use crate::connect::{AsyncReadAndWrite, ServerConnector}; diff --git a/tokio-xmpp/src/client/connect.rs b/tokio-xmpp/src/client/connect.rs index 29d71024..41db57e0 100644 --- a/tokio-xmpp/src/client/connect.rs +++ b/tokio-xmpp/src/client/connect.rs @@ -1,5 +1,5 @@ use sasl::common::Credentials; -use xmpp_parsers::{ns, Jid}; +use xmpp_parsers::{jid::Jid, ns}; use crate::client::auth::auth; use crate::client::bind::bind; diff --git a/tokio-xmpp/src/client/simple_client.rs b/tokio-xmpp/src/client/simple_client.rs index 19ab2f97..bb406e69 100644 --- a/tokio-xmpp/src/client/simple_client.rs +++ b/tokio-xmpp/src/client/simple_client.rs @@ -1,8 +1,9 @@ use futures::{sink::SinkExt, Sink, Stream}; +use minidom::Element; use std::pin::Pin; use std::task::{Context, Poll}; use tokio_stream::StreamExt; -use xmpp_parsers::{ns, Element, Jid}; +use xmpp_parsers::{jid::Jid, ns}; use crate::connect::ServerConnector; use crate::stream_features::StreamFeatures; diff --git a/tokio-xmpp/src/component/connect.rs b/tokio-xmpp/src/component/connect.rs index 509172ee..63e66d07 100644 --- a/tokio-xmpp/src/component/connect.rs +++ b/tokio-xmpp/src/component/connect.rs @@ -1,4 +1,4 @@ -use xmpp_parsers::{ns, Jid}; +use xmpp_parsers::{jid::Jid, ns}; use crate::connect::ServerConnector; use crate::{xmpp_stream::XMPPStream, Error}; diff --git a/tokio-xmpp/src/component/mod.rs b/tokio-xmpp/src/component/mod.rs index 5dc6860d..17b1b38e 100644 --- a/tokio-xmpp/src/component/mod.rs +++ b/tokio-xmpp/src/component/mod.rs @@ -2,10 +2,11 @@ //! XMPP server under a JID consisting of just a domain name. They are //! allowed to use any user and resource identifiers in their stanzas. use futures::{sink::SinkExt, task::Poll, Sink, Stream}; +use minidom::Element; use std::pin::Pin; use std::str::FromStr; use std::task::Context; -use xmpp_parsers::{ns, Element, Jid}; +use xmpp_parsers::{jid::Jid, ns}; use self::connect::component_login; diff --git a/tokio-xmpp/src/connect.rs b/tokio-xmpp/src/connect.rs index 79f79de3..ebd1781f 100644 --- a/tokio-xmpp/src/connect.rs +++ b/tokio-xmpp/src/connect.rs @@ -2,7 +2,7 @@ use sasl::common::ChannelBinding; use tokio::io::{AsyncRead, AsyncWrite}; -use xmpp_parsers::Jid; +use xmpp_parsers::jid::Jid; use crate::xmpp_stream::XMPPStream; diff --git a/tokio-xmpp/src/error.rs b/tokio-xmpp/src/error.rs index 7cf8879e..c0299c40 100644 --- a/tokio-xmpp/src/error.rs +++ b/tokio-xmpp/src/error.rs @@ -6,7 +6,7 @@ use std::io::Error as IoError; use std::str::Utf8Error; use xmpp_parsers::sasl::DefinedCondition as SaslDefinedCondition; -use xmpp_parsers::{Error as ParsersError, JidParseError}; +use xmpp_parsers::{jid::Error as JidParseError, Error as ParsersError}; use crate::connect::ServerConnectorError; diff --git a/tokio-xmpp/src/event.rs b/tokio-xmpp/src/event.rs index 2550f593..05eaf9e6 100644 --- a/tokio-xmpp/src/event.rs +++ b/tokio-xmpp/src/event.rs @@ -1,5 +1,6 @@ use super::Error; -use xmpp_parsers::{Element, Jid}; +use minidom::Element; +use xmpp_parsers::jid::Jid; /// High-level event on the Stream implemented by Client and Component #[derive(Debug)] diff --git a/tokio-xmpp/src/lib.rs b/tokio-xmpp/src/lib.rs index ba2e6048..165149df 100644 --- a/tokio-xmpp/src/lib.rs +++ b/tokio-xmpp/src/lib.rs @@ -43,6 +43,6 @@ mod error; pub use crate::error::{AuthError, Error, ParseError, ProtocolError}; // Re-exports -pub use minidom::Element; +pub use minidom; pub use xmpp_parsers as parsers; -pub use xmpp_parsers::{BareJid, FullJid, Jid, JidParseError}; +pub use xmpp_parsers::jid; diff --git a/tokio-xmpp/src/starttls/client.rs b/tokio-xmpp/src/starttls/client.rs index 2a2395cd..d1d79761 100644 --- a/tokio-xmpp/src/starttls/client.rs +++ b/tokio-xmpp/src/starttls/client.rs @@ -1,6 +1,6 @@ use std::str::FromStr; -use xmpp_parsers::Jid; +use xmpp_parsers::jid::Jid; use crate::{AsyncClient, AsyncConfig, Error, SimpleClient}; diff --git a/tokio-xmpp/src/starttls/mod.rs b/tokio-xmpp/src/starttls/mod.rs index f80438a9..cefa4def 100644 --- a/tokio-xmpp/src/starttls/mod.rs +++ b/tokio-xmpp/src/starttls/mod.rs @@ -18,12 +18,13 @@ use { tokio_native_tls::{TlsConnector, TlsStream}, }; +use minidom::Element; use sasl::common::ChannelBinding; use tokio::{ io::{AsyncRead, AsyncWrite}, net::TcpStream, }; -use xmpp_parsers::{ns, Element, Jid}; +use xmpp_parsers::{jid::Jid, ns}; use crate::{connect::ServerConnector, xmpp_codec::Packet, AsyncClient, SimpleClient}; use crate::{connect::ServerConnectorError, xmpp_stream::XMPPStream}; diff --git a/tokio-xmpp/src/stream_features.rs b/tokio-xmpp/src/stream_features.rs index 63263f3d..5599e841 100644 --- a/tokio-xmpp/src/stream_features.rs +++ b/tokio-xmpp/src/stream_features.rs @@ -1,7 +1,8 @@ //! Contains wrapper for `` use crate::error::AuthError; -use xmpp_parsers::{ns, Element}; +use minidom::Element; +use xmpp_parsers::ns; /// Wraps ``, usually the very first nonza of an /// XMPPStream. diff --git a/tokio-xmpp/src/stream_start.rs b/tokio-xmpp/src/stream_start.rs index 700f802c..5b37f81e 100644 --- a/tokio-xmpp/src/stream_start.rs +++ b/tokio-xmpp/src/stream_start.rs @@ -1,7 +1,8 @@ use futures::{sink::SinkExt, stream::StreamExt}; +use minidom::Element; use tokio::io::{AsyncRead, AsyncWrite}; use tokio_util::codec::Framed; -use xmpp_parsers::{ns, Element, Jid}; +use xmpp_parsers::{jid::Jid, ns}; use crate::xmpp_codec::{Packet, XmppCodec}; use crate::xmpp_stream::XMPPStream; diff --git a/tokio-xmpp/src/tcp/mod.rs b/tokio-xmpp/src/tcp/mod.rs index db246008..321ceca3 100644 --- a/tokio-xmpp/src/tcp/mod.rs +++ b/tokio-xmpp/src/tcp/mod.rs @@ -38,7 +38,7 @@ impl ServerConnector for TcpServerConnector { type Error = Error; async fn connect( &self, - jid: &xmpp_parsers::Jid, + jid: &xmpp_parsers::jid::Jid, ns: &str, ) -> Result, Self::Error> { let stream = TcpStream::connect(&*self.0) diff --git a/tokio-xmpp/src/xmpp_codec.rs b/tokio-xmpp/src/xmpp_codec.rs index 29123642..fd56a6d2 100644 --- a/tokio-xmpp/src/xmpp_codec.rs +++ b/tokio-xmpp/src/xmpp_codec.rs @@ -4,6 +4,7 @@ use crate::Error; use bytes::{BufMut, BytesMut}; use log::debug; use minidom::tree_builder::TreeBuilder; +use minidom::Element; use rxml::{Parse, RawParser}; use std::collections::HashMap; use std::fmt::Write; @@ -11,7 +12,6 @@ use std::io; #[cfg(feature = "syntax-highlighting")] use std::sync::OnceLock; use tokio_util::codec::{Decoder, Encoder}; -use xmpp_parsers::Element; #[cfg(feature = "syntax-highlighting")] static PS: OnceLock = OnceLock::new(); diff --git a/tokio-xmpp/src/xmpp_stream.rs b/tokio-xmpp/src/xmpp_stream.rs index 57bd8e52..97d84b2e 100644 --- a/tokio-xmpp/src/xmpp_stream.rs +++ b/tokio-xmpp/src/xmpp_stream.rs @@ -2,12 +2,13 @@ use futures::sink::Send; use futures::{sink::SinkExt, task::Poll, Sink, Stream}; +use minidom::Element; use rand::{thread_rng, Rng}; use std::pin::Pin; use std::task::Context; use tokio::io::{AsyncRead, AsyncWrite}; use tokio_util::codec::Framed; -use xmpp_parsers::{Element, Jid}; +use xmpp_parsers::jid::Jid; use crate::stream_features::StreamFeatures; use crate::stream_start;