cleanup jabber crate
This commit is contained in:
		
							parent
							
								
									ea87cc407c
								
							
						
					
					
						commit
						b859cd7f78
					
				|  | @ -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 rsasl::config::SASLConfig; | ||||||
| use stanza::{ | use stanza::{ | ||||||
|     client::Stanza, |  | ||||||
|     sasl::Mechanisms, |     sasl::Mechanisms, | ||||||
|     stream::{Feature, Features}, |     stream::{Feature, Features}, | ||||||
| }; | }; | ||||||
| use tokio::sync::Mutex; |  | ||||||
| 
 | 
 | ||||||
| use crate::{ | use crate::{ | ||||||
|     connection::{Tls, Unencrypted}, |     connection::{Tls, Unencrypted}, | ||||||
|     jabber_stream::bound_stream::{BoundJabberReader, BoundJabberStream}, |     jabber_stream::bound_stream::BoundJabberStream, | ||||||
|     Connection, Error, JabberStream, Result, JID, |     Connection, Error, JabberStream, Result, JID, | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| pub async fn connect_and_login( | pub async fn connect_and_login( | ||||||
|     mut jid: &mut JID, |     jid: &mut JID, | ||||||
|     password: impl AsRef<str>, |     password: impl AsRef<str>, | ||||||
|     server: &mut String, |     server: &mut String, | ||||||
| ) -> Result<BoundJabberStream<Tls>> { | ) -> Result<BoundJabberStream<Tls>> { | ||||||
|  |  | ||||||
|  | @ -1,9 +1,7 @@ | ||||||
| use std::net::{IpAddr, SocketAddr}; | use std::net::{IpAddr, SocketAddr}; | ||||||
| use std::str; | use std::str; | ||||||
| use std::str::FromStr; | use std::str::FromStr; | ||||||
| use std::sync::Arc; |  | ||||||
| 
 | 
 | ||||||
| use rsasl::config::SASLConfig; |  | ||||||
| use tokio::net::TcpStream; | use tokio::net::TcpStream; | ||||||
| use tokio_native_tls::native_tls::TlsConnector; | use tokio_native_tls::native_tls::TlsConnector; | ||||||
| // TODO: use rustls
 | // TODO: use rustls
 | ||||||
|  |  | ||||||
|  | @ -1,10 +1,8 @@ | ||||||
| use std::pin::pin; |  | ||||||
| use std::str::{self, FromStr}; | use std::str::{self, FromStr}; | ||||||
| use std::sync::Arc; | use std::sync::Arc; | ||||||
| 
 | 
 | ||||||
| use futures::{sink, stream, StreamExt}; |  | ||||||
| use jid::JID; | use jid::JID; | ||||||
| use peanuts::element::{FromContent, IntoElement}; | use peanuts::element::IntoElement; | ||||||
| use peanuts::{Reader, Writer}; | use peanuts::{Reader, Writer}; | ||||||
| use rsasl::prelude::{Mechname, SASLClient, SASLConfig}; | use rsasl::prelude::{Mechname, SASLClient, SASLConfig}; | ||||||
| use stanza::bind::{Bind, BindType, FullJidType, ResourceType}; | use stanza::bind::{Bind, BindType, FullJidType, ResourceType}; | ||||||
|  | @ -141,7 +139,7 @@ where | ||||||
|         let mut session = sasl.start_suggested(&offered_mechs)?; |         let mut session = sasl.start_suggested(&offered_mechs)?; | ||||||
|         let selected_mechanism = session.get_mechname().as_str().to_owned(); |         let selected_mechanism = session.get_mechname().as_str().to_owned(); | ||||||
|         debug!("selected mech: {:?}", selected_mechanism); |         debug!("selected mech: {:?}", selected_mechanism); | ||||||
|         let mut data: Option<Vec<u8>> = None; |         let mut data: Option<Vec<u8>>; | ||||||
| 
 | 
 | ||||||
|         if !session.are_we_first() { |         if !session.are_we_first() { | ||||||
|             // if not first mention the mechanism then get challenge data
 |             // if not first mention the mechanism then get challenge data
 | ||||||
|  | @ -409,13 +407,7 @@ impl std::fmt::Debug for JabberStream<Unencrypted> { | ||||||
| 
 | 
 | ||||||
| #[cfg(test)] | #[cfg(test)] | ||||||
| mod tests { | mod tests { | ||||||
|     use std::time::Duration; |  | ||||||
| 
 |  | ||||||
|     use super::*; |  | ||||||
|     use crate::connection::Connection; |  | ||||||
|     use futures::sink; |  | ||||||
|     use test_log::test; |     use test_log::test; | ||||||
|     use tokio::time::sleep; |  | ||||||
| 
 | 
 | ||||||
|     #[test(tokio::test)] |     #[test(tokio::test)] | ||||||
|     async fn start_stream() { |     async fn start_stream() { | ||||||
|  |  | ||||||
|  | @ -1,9 +1,6 @@ | ||||||
| use std::ops::{Deref, DerefMut}; | use std::ops::{Deref, DerefMut}; | ||||||
| 
 | 
 | ||||||
| use peanuts::{Reader, Writer}; | use tokio::io::{AsyncRead, AsyncWrite}; | ||||||
| use tokio::io::{AsyncRead, AsyncWrite, ReadHalf, WriteHalf}; |  | ||||||
| 
 |  | ||||||
| use crate::Error; |  | ||||||
| 
 | 
 | ||||||
| use super::{JabberReader, JabberStream, JabberWriter}; | use super::{JabberReader, JabberStream, JabberWriter}; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -8,7 +8,6 @@ pub mod error; | ||||||
| pub mod jabber_stream; | pub mod jabber_stream; | ||||||
| 
 | 
 | ||||||
| pub use connection::Connection; | pub use connection::Connection; | ||||||
| use connection::Tls; |  | ||||||
| pub use error::Error; | pub use error::Error; | ||||||
| pub use jabber_stream::JabberStream; | pub use jabber_stream::JabberStream; | ||||||
| pub use jid::JID; | pub use jid::JID; | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue