Only expose one error type in crate root
This commit is contained in:
parent
34796c90d4
commit
84511b54a0
6 changed files with 40 additions and 55 deletions
|
|
@ -5,6 +5,7 @@ use tokio::io::{AsyncRead, AsyncWrite};
|
|||
use xmpp_parsers::jid::Jid;
|
||||
|
||||
use crate::xmpp_stream::XMPPStream;
|
||||
use crate::Error;
|
||||
|
||||
/// trait returned wrapped in XMPPStream by ServerConnector
|
||||
pub trait AsyncReadAndWrite: AsyncRead + AsyncWrite + Unpin + Send {}
|
||||
|
|
@ -17,19 +18,17 @@ pub trait ServerConnectorError: std::error::Error + Sync + Send {}
|
|||
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 <stream headers are exchanged
|
||||
fn connect(
|
||||
&self,
|
||||
jid: &Jid,
|
||||
ns: &str,
|
||||
) -> impl std::future::Future<Output = Result<XMPPStream<Self::Stream>, Self::Error>> + Send;
|
||||
) -> impl std::future::Future<Output = Result<XMPPStream<Self::Stream>, 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<ChannelBinding, Self::Error> {
|
||||
fn channel_binding(_stream: &Self::Stream) -> Result<ChannelBinding, Error> {
|
||||
Ok(ChannelBinding::None)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue