cleanup jabber crate

This commit is contained in:
cel 🌸 2025-02-25 19:50:15 +00:00
parent ea87cc407c
commit b859cd7f78
5 changed files with 5 additions and 31 deletions

View File

@ -1,29 +1,17 @@
use std::{
borrow::Borrow,
future::Future,
pin::pin,
sync::Arc,
task::{ready, Poll},
};
use futures::{FutureExt, Sink, SinkExt, Stream, StreamExt};
use jid::ParseError;
use rsasl::config::SASLConfig;
use stanza::{
client::Stanza,
sasl::Mechanisms,
stream::{Feature, Features},
};
use tokio::sync::Mutex;
use crate::{
connection::{Tls, Unencrypted},
jabber_stream::bound_stream::{BoundJabberReader, BoundJabberStream},
jabber_stream::bound_stream::BoundJabberStream,
Connection, Error, JabberStream, Result, JID,
};
pub async fn connect_and_login(
mut jid: &mut JID,
jid: &mut JID,
password: impl AsRef<str>,
server: &mut String,
) -> Result<BoundJabberStream<Tls>> {

View File

@ -1,9 +1,7 @@
use std::net::{IpAddr, SocketAddr};
use std::str;
use std::str::FromStr;
use std::sync::Arc;
use rsasl::config::SASLConfig;
use tokio::net::TcpStream;
use tokio_native_tls::native_tls::TlsConnector;
// TODO: use rustls

View File

@ -1,10 +1,8 @@
use std::pin::pin;
use std::str::{self, FromStr};
use std::sync::Arc;
use futures::{sink, stream, StreamExt};
use jid::JID;
use peanuts::element::{FromContent, IntoElement};
use peanuts::element::IntoElement;
use peanuts::{Reader, Writer};
use rsasl::prelude::{Mechname, SASLClient, SASLConfig};
use stanza::bind::{Bind, BindType, FullJidType, ResourceType};
@ -141,7 +139,7 @@ where
let mut session = sasl.start_suggested(&offered_mechs)?;
let selected_mechanism = session.get_mechname().as_str().to_owned();
debug!("selected mech: {:?}", selected_mechanism);
let mut data: Option<Vec<u8>> = None;
let mut data: Option<Vec<u8>>;
if !session.are_we_first() {
// if not first mention the mechanism then get challenge data
@ -409,13 +407,7 @@ impl std::fmt::Debug for JabberStream<Unencrypted> {
#[cfg(test)]
mod tests {
use std::time::Duration;
use super::*;
use crate::connection::Connection;
use futures::sink;
use test_log::test;
use tokio::time::sleep;
#[test(tokio::test)]
async fn start_stream() {

View File

@ -1,9 +1,6 @@
use std::ops::{Deref, DerefMut};
use peanuts::{Reader, Writer};
use tokio::io::{AsyncRead, AsyncWrite, ReadHalf, WriteHalf};
use crate::Error;
use tokio::io::{AsyncRead, AsyncWrite};
use super::{JabberReader, JabberStream, JabberWriter};

View File

@ -8,7 +8,6 @@ pub mod error;
pub mod jabber_stream;
pub use connection::Connection;
use connection::Tls;
pub use error::Error;
pub use jabber_stream::JabberStream;
pub use jid::JID;