tokio-xmpp: simplify examples by requiring specific TLS features

This commit is contained in:
Jonas Schäfer 2025-05-10 16:41:35 +02:00
commit e3a4aae42d
6 changed files with 4 additions and 74 deletions

View file

@ -1,7 +1,6 @@
use futures::{SinkExt, StreamExt};
use tokio::{self, io, net::TcpSocket};
#[cfg(feature = "rustls-any-backend")]
use tokio_xmpp::rustls;
use tokio_xmpp::{
minidom::Element,
@ -9,24 +8,12 @@ use tokio_xmpp::{
xmlstream::{accept_stream, StreamHeader, Timeouts},
};
#[cfg(all(
feature = "rustls-any-backend",
not(any(feature = "aws_lc_rs", feature = "ring"))
))]
compile_error!("using rustls (e.g. via the ktls feature) needs an enabled rustls backend feature (either aws_lc_rs or ring).");
#[tokio::main]
async fn main() -> Result<(), io::Error> {
#[cfg(all(feature = "aws_lc_rs", not(feature = "ring")))]
rustls::crypto::aws_lc_rs::default_provider()
.install_default()
.expect("failed to install rustls crypto provider");
#[cfg(all(feature = "ring"))]
rustls::crypto::ring::default_provider()
.install_default()
.expect("failed to install rustls crypto provider");
// TCP socket
let address = "127.0.0.1:5222".parse().unwrap();
let socket = TcpSocket::new_v4()?;