tokio-xmpp: Import Jid, BareJid and Element properly

xmpp-parsers has stopped reexporting them, instead it reexports only the
crates themselves.
This commit is contained in:
Emmanuel Gil Peyrot 2024-07-24 20:39:27 +02:00 • committed by Jonas Schäfer
commit e9b226e1ae
21 changed files with 34 additions and 22 deletions

View file

@ -1,4 +1,5 @@
use futures::stream::StreamExt; use futures::stream::StreamExt;
use minidom::Element;
use std::env::args; use std::env::args;
use std::process::exit; use std::process::exit;
use std::str::FromStr; use std::str::FromStr;
@ -6,9 +7,9 @@ use tokio_xmpp::AsyncClient as Client;
use xmpp_parsers::{ use xmpp_parsers::{
disco::{DiscoInfoQuery, DiscoInfoResult}, disco::{DiscoInfoQuery, DiscoInfoResult},
iq::{Iq, IqType}, iq::{Iq, IqType},
jid::{BareJid, Jid},
ns, ns,
server_info::ServerInfo, server_info::ServerInfo,
BareJid, Element, Jid,
}; };
#[tokio::main] #[tokio::main]

View file

@ -1,4 +1,5 @@
use futures::stream::StreamExt; use futures::stream::StreamExt;
use minidom::Element;
use std::env::args; use std::env::args;
use std::fs::{create_dir_all, File}; use std::fs::{create_dir_all, File};
use std::io::{self, Write}; use std::io::{self, Write};
@ -11,6 +12,7 @@ use xmpp_parsers::{
disco::{DiscoInfoQuery, DiscoInfoResult, Feature, Identity}, disco::{DiscoInfoQuery, DiscoInfoResult, Feature, Identity},
hashes::Algo, hashes::Algo,
iq::{Iq, IqType}, iq::{Iq, IqType},
jid::{BareJid, Jid},
message::Message, message::Message,
ns, ns,
presence::{Presence, Type as PresenceType}, presence::{Presence, Type as PresenceType},
@ -20,7 +22,6 @@ use xmpp_parsers::{
NodeName, NodeName,
}, },
stanza_error::{DefinedCondition, ErrorType, StanzaError}, stanza_error::{DefinedCondition, ErrorType, StanzaError},
BareJid, Element, Jid,
}; };
#[tokio::main] #[tokio::main]

View file

@ -1,11 +1,12 @@
use futures::stream::StreamExt; use futures::stream::StreamExt;
use minidom::Element;
use std::env::args; use std::env::args;
use std::process::exit; use std::process::exit;
use std::str::FromStr; use std::str::FromStr;
use tokio_xmpp::AsyncClient as Client; use tokio_xmpp::AsyncClient as Client;
use xmpp_parsers::jid::{BareJid, Jid};
use xmpp_parsers::message::{Body, Message, MessageType}; use xmpp_parsers::message::{Body, Message, MessageType};
use xmpp_parsers::presence::{Presence, Show as PresenceShow, Type as PresenceType}; use xmpp_parsers::presence::{Presence, Show as PresenceShow, Type as PresenceType};
use xmpp_parsers::{BareJid, Element, Jid};
#[tokio::main] #[tokio::main]
async fn main() { async fn main() {

View file

@ -1,11 +1,12 @@
use futures::stream::StreamExt; use futures::stream::StreamExt;
use minidom::Element;
use std::env::args; use std::env::args;
use std::process::exit; use std::process::exit;
use std::str::FromStr; use std::str::FromStr;
use tokio_xmpp::tcp::TcpComponent as Component; use tokio_xmpp::tcp::TcpComponent as Component;
use xmpp_parsers::jid::Jid;
use xmpp_parsers::message::{Body, Message, MessageType}; use xmpp_parsers::message::{Body, Message, MessageType};
use xmpp_parsers::presence::{Presence, Show as PresenceShow, Type as PresenceType}; use xmpp_parsers::presence::{Presence, Show as PresenceShow, Type as PresenceType};
use xmpp_parsers::{Element, Jid};
#[tokio::main] #[tokio::main]
async fn main() { async fn main() {

View file

@ -3,8 +3,8 @@ use std::io::{stdin, Read};
use std::process::exit; use std::process::exit;
use std::str::FromStr; use std::str::FromStr;
use tokio_xmpp::SimpleClient as Client; use tokio_xmpp::SimpleClient as Client;
use xmpp_parsers::jid::Jid;
use xmpp_parsers::message::{Body, Message}; use xmpp_parsers::message::{Body, Message};
use xmpp_parsers::Jid;
#[tokio::main] #[tokio::main]
async fn main() { async fn main() {

View file

@ -1,9 +1,10 @@
use futures::{sink::SinkExt, task::Poll, Future, Sink, Stream}; use futures::{sink::SinkExt, task::Poll, Future, Sink, Stream};
use minidom::Element;
use std::mem::replace; use std::mem::replace;
use std::pin::Pin; use std::pin::Pin;
use std::task::Context; use std::task::Context;
use tokio::task::JoinHandle; use tokio::task::JoinHandle;
use xmpp_parsers::{ns, Element, Jid}; use xmpp_parsers::{jid::Jid, ns};
use super::connect::client_login; use super::connect::client_login;
use crate::connect::{AsyncReadAndWrite, ServerConnector}; use crate::connect::{AsyncReadAndWrite, ServerConnector};

View file

@ -1,5 +1,5 @@
use sasl::common::Credentials; use sasl::common::Credentials;
use xmpp_parsers::{ns, Jid}; use xmpp_parsers::{jid::Jid, ns};
use crate::client::auth::auth; use crate::client::auth::auth;
use crate::client::bind::bind; use crate::client::bind::bind;

View file

@ -1,8 +1,9 @@
use futures::{sink::SinkExt, Sink, Stream}; use futures::{sink::SinkExt, Sink, Stream};
use minidom::Element;
use std::pin::Pin; use std::pin::Pin;
use std::task::{Context, Poll}; use std::task::{Context, Poll};
use tokio_stream::StreamExt; use tokio_stream::StreamExt;
use xmpp_parsers::{ns, Element, Jid}; use xmpp_parsers::{jid::Jid, ns};
use crate::connect::ServerConnector; use crate::connect::ServerConnector;
use crate::stream_features::StreamFeatures; use crate::stream_features::StreamFeatures;

View file

@ -1,4 +1,4 @@
use xmpp_parsers::{ns, Jid}; use xmpp_parsers::{jid::Jid, ns};
use crate::connect::ServerConnector; use crate::connect::ServerConnector;
use crate::{xmpp_stream::XMPPStream, Error}; use crate::{xmpp_stream::XMPPStream, Error};

View file

@ -2,10 +2,11 @@
//! XMPP server under a JID consisting of just a domain name. They are //! XMPP server under a JID consisting of just a domain name. They are
//! allowed to use any user and resource identifiers in their stanzas. //! allowed to use any user and resource identifiers in their stanzas.
use futures::{sink::SinkExt, task::Poll, Sink, Stream}; use futures::{sink::SinkExt, task::Poll, Sink, Stream};
use minidom::Element;
use std::pin::Pin; use std::pin::Pin;
use std::str::FromStr; use std::str::FromStr;
use std::task::Context; use std::task::Context;
use xmpp_parsers::{ns, Element, Jid}; use xmpp_parsers::{jid::Jid, ns};
use self::connect::component_login; use self::connect::component_login;

View file

@ -2,7 +2,7 @@
use sasl::common::ChannelBinding; use sasl::common::ChannelBinding;
use tokio::io::{AsyncRead, AsyncWrite}; use tokio::io::{AsyncRead, AsyncWrite};
use xmpp_parsers::Jid; use xmpp_parsers::jid::Jid;
use crate::xmpp_stream::XMPPStream; use crate::xmpp_stream::XMPPStream;

View file

@ -6,7 +6,7 @@ use std::io::Error as IoError;
use std::str::Utf8Error; use std::str::Utf8Error;
use xmpp_parsers::sasl::DefinedCondition as SaslDefinedCondition; 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; use crate::connect::ServerConnectorError;

View file

@ -1,5 +1,6 @@
use super::Error; 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 /// High-level event on the Stream implemented by Client and Component
#[derive(Debug)] #[derive(Debug)]

View file

@ -43,6 +43,6 @@ mod error;
pub use crate::error::{AuthError, Error, ParseError, ProtocolError}; pub use crate::error::{AuthError, Error, ParseError, ProtocolError};
// Re-exports // Re-exports
pub use minidom::Element; pub use minidom;
pub use xmpp_parsers as parsers; pub use xmpp_parsers as parsers;
pub use xmpp_parsers::{BareJid, FullJid, Jid, JidParseError}; pub use xmpp_parsers::jid;

View file

@ -1,6 +1,6 @@
use std::str::FromStr; use std::str::FromStr;
use xmpp_parsers::Jid; use xmpp_parsers::jid::Jid;
use crate::{AsyncClient, AsyncConfig, Error, SimpleClient}; use crate::{AsyncClient, AsyncConfig, Error, SimpleClient};

View file

@ -18,12 +18,13 @@ use {
tokio_native_tls::{TlsConnector, TlsStream}, tokio_native_tls::{TlsConnector, TlsStream},
}; };
use minidom::Element;
use sasl::common::ChannelBinding; use sasl::common::ChannelBinding;
use tokio::{ use tokio::{
io::{AsyncRead, AsyncWrite}, io::{AsyncRead, AsyncWrite},
net::TcpStream, 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::ServerConnector, xmpp_codec::Packet, AsyncClient, SimpleClient};
use crate::{connect::ServerConnectorError, xmpp_stream::XMPPStream}; use crate::{connect::ServerConnectorError, xmpp_stream::XMPPStream};

View file

@ -1,7 +1,8 @@
//! Contains wrapper for `<stream:features/>` //! Contains wrapper for `<stream:features/>`
use crate::error::AuthError; use crate::error::AuthError;
use xmpp_parsers::{ns, Element}; use minidom::Element;
use xmpp_parsers::ns;
/// Wraps `<stream:features/>`, usually the very first nonza of an /// Wraps `<stream:features/>`, usually the very first nonza of an
/// XMPPStream. /// XMPPStream.

View file

@ -1,7 +1,8 @@
use futures::{sink::SinkExt, stream::StreamExt}; use futures::{sink::SinkExt, stream::StreamExt};
use minidom::Element;
use tokio::io::{AsyncRead, AsyncWrite}; use tokio::io::{AsyncRead, AsyncWrite};
use tokio_util::codec::Framed; 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_codec::{Packet, XmppCodec};
use crate::xmpp_stream::XMPPStream; use crate::xmpp_stream::XMPPStream;

View file

@ -38,7 +38,7 @@ impl ServerConnector for TcpServerConnector {
type Error = Error; type Error = Error;
async fn connect( async fn connect(
&self, &self,
jid: &xmpp_parsers::Jid, jid: &xmpp_parsers::jid::Jid,
ns: &str, ns: &str,
) -> Result<XMPPStream<Self::Stream>, Self::Error> { ) -> Result<XMPPStream<Self::Stream>, Self::Error> {
let stream = TcpStream::connect(&*self.0) let stream = TcpStream::connect(&*self.0)

View file

@ -4,6 +4,7 @@ use crate::Error;
use bytes::{BufMut, BytesMut}; use bytes::{BufMut, BytesMut};
use log::debug; use log::debug;
use minidom::tree_builder::TreeBuilder; use minidom::tree_builder::TreeBuilder;
use minidom::Element;
use rxml::{Parse, RawParser}; use rxml::{Parse, RawParser};
use std::collections::HashMap; use std::collections::HashMap;
use std::fmt::Write; use std::fmt::Write;
@ -11,7 +12,6 @@ use std::io;
#[cfg(feature = "syntax-highlighting")] #[cfg(feature = "syntax-highlighting")]
use std::sync::OnceLock; use std::sync::OnceLock;
use tokio_util::codec::{Decoder, Encoder}; use tokio_util::codec::{Decoder, Encoder};
use xmpp_parsers::Element;
#[cfg(feature = "syntax-highlighting")] #[cfg(feature = "syntax-highlighting")]
static PS: OnceLock<syntect::parsing::SyntaxSet> = OnceLock::new(); static PS: OnceLock<syntect::parsing::SyntaxSet> = OnceLock::new();

View file

@ -2,12 +2,13 @@
use futures::sink::Send; use futures::sink::Send;
use futures::{sink::SinkExt, task::Poll, Sink, Stream}; use futures::{sink::SinkExt, task::Poll, Sink, Stream};
use minidom::Element;
use rand::{thread_rng, Rng}; use rand::{thread_rng, Rng};
use std::pin::Pin; use std::pin::Pin;
use std::task::Context; use std::task::Context;
use tokio::io::{AsyncRead, AsyncWrite}; use tokio::io::{AsyncRead, AsyncWrite};
use tokio_util::codec::Framed; use tokio_util::codec::Framed;
use xmpp_parsers::{Element, Jid}; use xmpp_parsers::jid::Jid;
use crate::stream_features::StreamFeatures; use crate::stream_features::StreamFeatures;
use crate::stream_start; use crate::stream_start;