//! `ServerConnector` provides streams for XMPP clients use sasl::common::ChannelBinding; use tokio::io::{AsyncRead, AsyncWrite}; use xmpp_parsers::Jid; use crate::xmpp_stream::XMPPStream; /// trait returned wrapped in XMPPStream by ServerConnector pub trait AsyncReadAndWrite: AsyncRead + AsyncWrite + Unpin + Send {} impl AsyncReadAndWrite for T {} /// Trait that must be extended by the implementation of ServerConnector pub trait ServerConnectorError: std::error::Error + Send {} /// Trait called to connect to an XMPP server, perhaps called multiple times pub trait ServerConnector: Clone + core::fmt::Debug + Send + Unpin + 'static { /// The type of Stream this ServerConnector produces type Stream: AsyncReadAndWrite; /// Error type to return type Error: ServerConnectorError; /// This must return the connection ready to login, ie if starttls is involved, after TLS has been started, and then after the impl std::future::Future, Self::Error>> + Send; /// Return channel binding data if available /// do not fail if channel binding is simply unavailable, just return Ok(None) /// this should only be called after the TLS handshake is finished fn channel_binding(_stream: &Self::Stream) -> Result { Ok(ChannelBinding::None) } }