diff --git a/tokio-xmpp/src/client/async_client.rs b/tokio-xmpp/src/client/async_client.rs index 025c2aa..403aa98 100644 --- a/tokio-xmpp/src/client/async_client.rs +++ b/tokio-xmpp/src/client/async_client.rs @@ -7,7 +7,7 @@ use tokio::net::TcpStream; use tokio::task::JoinHandle; #[cfg(feature = "tls-native")] use tokio_native_tls::TlsStream; -#[cfg(feature = "tls-rust")] +#[cfg(all(feature = "tls-rust", not(feature = "tls-native")))] use tokio_rustls::client::TlsStream; use xmpp_parsers::{ns, Element, Jid}; diff --git a/tokio-xmpp/src/client/simple_client.rs b/tokio-xmpp/src/client/simple_client.rs index a2fe69e..7fde073 100644 --- a/tokio-xmpp/src/client/simple_client.rs +++ b/tokio-xmpp/src/client/simple_client.rs @@ -7,7 +7,7 @@ use std::task::{Context, Poll}; use tokio::net::TcpStream; #[cfg(feature = "tls-native")] use tokio_native_tls::TlsStream; -#[cfg(feature = "tls-rust")] +#[cfg(all(feature = "tls-rust", not(feature = "tls-native")))] use tokio_rustls::client::TlsStream; use tokio_stream::StreamExt; use xmpp_parsers::{ns, Element, Jid}; diff --git a/tokio-xmpp/src/error.rs b/tokio-xmpp/src/error.rs index 82f7e74..96311f0 100644 --- a/tokio-xmpp/src/error.rs +++ b/tokio-xmpp/src/error.rs @@ -6,9 +6,9 @@ use std::error::Error as StdError; use std::fmt; use std::io::Error as IoError; use std::str::Utf8Error; -#[cfg(feature = "tls-rust")] +#[cfg(all(feature = "tls-rust", not(feature = "tls-native")))] use tokio_rustls::rustls::client::InvalidDnsNameError; -#[cfg(feature = "tls-rust")] +#[cfg(all(feature = "tls-rust", not(feature = "tls-native")))] use tokio_rustls::rustls::Error as TlsError; use trust_dns_proto::error::ProtoError; use trust_dns_resolver::error::ResolveError; @@ -34,7 +34,7 @@ pub enum Error { Auth(AuthError), /// TLS error Tls(TlsError), - #[cfg(feature = "tls-rust")] + #[cfg(all(feature = "tls-rust", not(feature = "tls-native")))] /// DNS name parsing error DnsNameError(InvalidDnsNameError), /// Connection closed @@ -57,7 +57,7 @@ impl fmt::Display for Error { Error::Protocol(e) => write!(fmt, "protocol error: {}", e), Error::Auth(e) => write!(fmt, "authentication error: {}", e), Error::Tls(e) => write!(fmt, "TLS error: {}", e), - #[cfg(feature = "tls-rust")] + #[cfg(all(feature = "tls-rust", not(feature = "tls-native")))] Error::DnsNameError(e) => write!(fmt, "DNS name error: {}", e), Error::Disconnected => write!(fmt, "disconnected"), Error::InvalidState => write!(fmt, "invalid state"), @@ -117,7 +117,7 @@ impl From for Error { } } -#[cfg(feature = "tls-rust")] +#[cfg(all(feature = "tls-rust", not(feature = "tls-native")))] impl From for Error { fn from(e: InvalidDnsNameError) -> Self { Error::DnsNameError(e) diff --git a/tokio-xmpp/src/lib.rs b/tokio-xmpp/src/lib.rs index d00ef29..214b6f6 100644 --- a/tokio-xmpp/src/lib.rs +++ b/tokio-xmpp/src/lib.rs @@ -2,6 +2,9 @@ #![deny(unsafe_code, missing_docs, bare_trait_objects)] +#[cfg(all(feature = "tls-native", feature = "tls-rust"))] +compile_error!("Both tls-native and tls-rust features can't be enabled at the same time."); + mod starttls; mod stream_start; mod xmpp_codec; diff --git a/tokio-xmpp/src/starttls.rs b/tokio-xmpp/src/starttls.rs index c355149..31a05ef 100644 --- a/tokio-xmpp/src/starttls.rs +++ b/tokio-xmpp/src/starttls.rs @@ -1,6 +1,6 @@ use futures::{sink::SinkExt, stream::StreamExt}; -#[cfg(feature = "tls-rust")] +#[cfg(all(feature = "tls-rust", not(feature = "tls-native")))] use { std::convert::TryFrom, std::sync::Arc, @@ -37,7 +37,7 @@ async fn get_tls_stream( Ok(tls_stream) } -#[cfg(feature = "tls-rust")] +#[cfg(all(feature = "tls-rust", not(feature = "tls-native")))] async fn get_tls_stream( xmpp_stream: XMPPStream, ) -> Result, Error> {