tokio-xmpp: Error out when both tls-native and tls-rust features are enabled

If the user enables the tls-rust feature and forgets to disable
default-features (which includes tls-native), tell them and bail out.

The code was made to work anyway when both are enabled, and here it
defaults to tls-native. It does seem better to have one explicitely
choose one though hence the compile_error! message.

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
Maxime “pep” Buquet 2023-10-24 18:24:04 +02:00 committed by pep
commit a16f670ee6
5 changed files with 12 additions and 9 deletions

View file

@ -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<S: AsyncRead + AsyncWrite + Unpin>(
Ok(tls_stream)
}
#[cfg(feature = "tls-rust")]
#[cfg(all(feature = "tls-rust", not(feature = "tls-native")))]
async fn get_tls_stream<S: AsyncRead + AsyncWrite + Unpin>(
xmpp_stream: XMPPStream<S>,
) -> Result<TlsStream<S>, Error> {