Add tests for crate exports ; add structure to imports/exports
This commit is contained in:
parent
1b4a307919
commit
7991cef904
7 changed files with 77 additions and 32 deletions
|
|
@ -65,9 +65,9 @@ use quote::{quote, ToTokens};
|
||||||
use minidom::{IntoAttributeValue, Node};
|
use minidom::{IntoAttributeValue, Node};
|
||||||
|
|
||||||
mod error;
|
mod error;
|
||||||
pub use crate::error::Error;
|
|
||||||
|
|
||||||
mod parts;
|
mod parts;
|
||||||
|
|
||||||
|
pub use crate::error::Error;
|
||||||
pub use parts::{DomainPart, DomainRef, NodePart, NodeRef, ResourcePart, ResourceRef};
|
pub use parts::{DomainPart, DomainRef, NodePart, NodeRef, ResourcePart, ResourceRef};
|
||||||
|
|
||||||
fn length_check(len: usize, error_empty: Error, error_too_long: Error) -> Result<(), Error> {
|
fn length_check(len: usize, error_empty: Error, error_too_long: Error) -> Result<(), Error> {
|
||||||
|
|
|
||||||
|
|
@ -293,3 +293,22 @@ pub mod fast;
|
||||||
|
|
||||||
/// XEP-0490: Message Displayed Synchronization
|
/// XEP-0490: Message Displayed Synchronization
|
||||||
pub mod message_displayed;
|
pub mod message_displayed;
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
#[test]
|
||||||
|
fn reexports() {
|
||||||
|
#[allow(unused_imports)]
|
||||||
|
use crate::blake2;
|
||||||
|
#[allow(unused_imports)]
|
||||||
|
use crate::jid;
|
||||||
|
#[allow(unused_imports)]
|
||||||
|
use crate::minidom;
|
||||||
|
#[allow(unused_imports)]
|
||||||
|
use crate::sha1;
|
||||||
|
#[allow(unused_imports)]
|
||||||
|
use crate::sha2;
|
||||||
|
#[allow(unused_imports)]
|
||||||
|
use crate::sha3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,6 @@ pin-project-lite = { version = "0.2" }
|
||||||
# same repository dependencies
|
# same repository dependencies
|
||||||
sasl = { version = "0.5", path = "../sasl" }
|
sasl = { version = "0.5", path = "../sasl" }
|
||||||
xmpp-parsers = { version = "0.21", path = "../parsers" }
|
xmpp-parsers = { version = "0.21", path = "../parsers" }
|
||||||
minidom = { version = "0.16", path = "../minidom" }
|
|
||||||
xso = { version = "0.1", path = "../xso" }
|
xso = { version = "0.1", path = "../xso" }
|
||||||
|
|
||||||
# these are only needed for starttls ServerConnector support
|
# these are only needed for starttls ServerConnector support
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,11 @@
|
||||||
use futures::{SinkExt, StreamExt};
|
use futures::{SinkExt, StreamExt};
|
||||||
use tokio::{self, io, net::TcpSocket};
|
use tokio::{self, io, net::TcpSocket};
|
||||||
|
|
||||||
use tokio_xmpp::parsers::stream_features::StreamFeatures;
|
use tokio_xmpp::{
|
||||||
use tokio_xmpp::xmlstream::{accept_stream, StreamHeader, Timeouts};
|
minidom::Element,
|
||||||
|
parsers::stream_features::StreamFeatures,
|
||||||
|
xmlstream::{accept_stream, StreamHeader, Timeouts},
|
||||||
|
};
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), io::Error> {
|
async fn main() -> Result<(), io::Error> {
|
||||||
|
|
@ -24,7 +27,7 @@ async fn main() -> Result<(), io::Error> {
|
||||||
.await?;
|
.await?;
|
||||||
let stream = stream.send_header(StreamHeader::default()).await?;
|
let stream = stream.send_header(StreamHeader::default()).await?;
|
||||||
let mut stream = stream
|
let mut stream = stream
|
||||||
.send_features::<minidom::Element>(&StreamFeatures::default())
|
.send_features::<Element>(&StreamFeatures::default())
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
|
|
|
||||||
|
|
@ -9,10 +9,10 @@ use std::io::Error as IoError;
|
||||||
use std::net::AddrParseError;
|
use std::net::AddrParseError;
|
||||||
use std::str::Utf8Error;
|
use std::str::Utf8Error;
|
||||||
|
|
||||||
use xmpp_parsers::sasl::DefinedCondition as SaslDefinedCondition;
|
use crate::{
|
||||||
use xmpp_parsers::{jid::Error as JidParseError, Error as ParsersError};
|
connect::ServerConnectorError, jid, minidom,
|
||||||
|
parsers::sasl::DefinedCondition as SaslDefinedCondition,
|
||||||
use crate::connect::ServerConnectorError;
|
};
|
||||||
|
|
||||||
/// Top-level error type
|
/// Top-level error type
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|
@ -20,7 +20,7 @@ pub enum Error {
|
||||||
/// I/O error
|
/// I/O error
|
||||||
Io(IoError),
|
Io(IoError),
|
||||||
/// Error parsing Jabber-Id
|
/// Error parsing Jabber-Id
|
||||||
JidParse(JidParseError),
|
JidParse(jid::Error),
|
||||||
/// Protocol-level error
|
/// Protocol-level error
|
||||||
Protocol(ProtocolError),
|
Protocol(ProtocolError),
|
||||||
/// Authentication error
|
/// Authentication error
|
||||||
|
|
@ -86,8 +86,8 @@ impl<T: ServerConnectorError + 'static> From<T> for Error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<JidParseError> for Error {
|
impl From<jid::Error> for Error {
|
||||||
fn from(e: JidParseError) -> Self {
|
fn from(e: jid::Error) -> Self {
|
||||||
Error::JidParse(e)
|
Error::JidParse(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -149,7 +149,7 @@ pub enum ProtocolError {
|
||||||
/// XML parser error
|
/// XML parser error
|
||||||
Parser(minidom::Error),
|
Parser(minidom::Error),
|
||||||
/// Error with expected stanza schema
|
/// Error with expected stanza schema
|
||||||
Parsers(ParsersError),
|
Parsers(xso::error::Error),
|
||||||
/// No TLS available
|
/// No TLS available
|
||||||
NoTls,
|
NoTls,
|
||||||
/// Invalid response to resource binding
|
/// Invalid response to resource binding
|
||||||
|
|
@ -197,8 +197,8 @@ impl From<minidom::Error> for Error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ParsersError> for ProtocolError {
|
impl From<xso::error::Error> for ProtocolError {
|
||||||
fn from(e: ParsersError) -> Self {
|
fn from(e: xso::error::Error) -> Self {
|
||||||
ProtocolError::Parsers(e)
|
ProtocolError::Parsers(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,28 +46,36 @@ compile_error!(
|
||||||
"when starttls feature enabled one of tls-native and tls-rust features must be enabled."
|
"when starttls feature enabled one of tls-native and tls-rust features must be enabled."
|
||||||
);
|
);
|
||||||
|
|
||||||
mod event;
|
pub use parsers::{jid, minidom};
|
||||||
pub use event::{Event, Stanza};
|
pub use xmpp_parsers as parsers;
|
||||||
pub mod connect;
|
|
||||||
pub mod stanzastream;
|
|
||||||
pub mod xmlstream;
|
|
||||||
|
|
||||||
mod client;
|
mod client;
|
||||||
pub use client::Client;
|
|
||||||
|
|
||||||
#[cfg(feature = "insecure-tcp")]
|
#[cfg(feature = "insecure-tcp")]
|
||||||
mod component;
|
mod component;
|
||||||
#[cfg(feature = "insecure-tcp")]
|
pub mod connect;
|
||||||
pub use crate::component::Component;
|
|
||||||
|
|
||||||
/// Detailed error types
|
/// Detailed error types
|
||||||
pub mod error;
|
pub mod error;
|
||||||
|
mod event;
|
||||||
|
pub mod stanzastream;
|
||||||
|
pub mod xmlstream;
|
||||||
|
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
/// Generic tokio_xmpp Error
|
/// Generic tokio_xmpp Error
|
||||||
pub use crate::error::Error;
|
pub use crate::error::Error;
|
||||||
|
pub use client::Client;
|
||||||
|
#[cfg(feature = "insecure-tcp")]
|
||||||
|
pub use component::Component;
|
||||||
|
pub use event::{Event, Stanza};
|
||||||
|
|
||||||
// Re-exports
|
#[cfg(test)]
|
||||||
pub use minidom;
|
mod tests {
|
||||||
pub use xmpp_parsers as parsers;
|
#[test]
|
||||||
pub use xmpp_parsers::jid;
|
fn reexports() {
|
||||||
|
#[allow(unused_imports)]
|
||||||
|
use crate::jid;
|
||||||
|
#[allow(unused_imports)]
|
||||||
|
use crate::minidom;
|
||||||
|
#[allow(unused_imports)]
|
||||||
|
use crate::parsers;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,13 +8,15 @@
|
||||||
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
|
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
|
||||||
|
|
||||||
pub use tokio_xmpp;
|
pub use tokio_xmpp;
|
||||||
pub use tokio_xmpp::jid::{ResourcePart, ResourceRef};
|
pub use tokio_xmpp::jid;
|
||||||
pub use tokio_xmpp::minidom;
|
pub use tokio_xmpp::minidom;
|
||||||
pub use tokio_xmpp::parsers;
|
pub use tokio_xmpp::parsers;
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate log;
|
extern crate log;
|
||||||
|
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
|
use jid::{ResourcePart, ResourceRef};
|
||||||
|
|
||||||
pub mod agent;
|
pub mod agent;
|
||||||
pub mod builder;
|
pub mod builder;
|
||||||
|
|
@ -30,7 +32,6 @@ pub mod presence;
|
||||||
pub mod pubsub;
|
pub mod pubsub;
|
||||||
pub mod upload;
|
pub mod upload;
|
||||||
|
|
||||||
// Module re-exports
|
|
||||||
pub use agent::Agent;
|
pub use agent::Agent;
|
||||||
pub use builder::{ClientBuilder, ClientType};
|
pub use builder::{ClientBuilder, ClientType};
|
||||||
pub use event::Event;
|
pub use event::Event;
|
||||||
|
|
@ -76,6 +77,21 @@ impl fmt::Display for RoomNick {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
#[test]
|
||||||
|
fn reexports() {
|
||||||
|
#[allow(unused_imports)]
|
||||||
|
use crate::jid;
|
||||||
|
#[allow(unused_imports)]
|
||||||
|
use crate::minidom;
|
||||||
|
#[allow(unused_imports)]
|
||||||
|
use crate::parsers;
|
||||||
|
#[allow(unused_imports)]
|
||||||
|
use crate::tokio_xmpp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// The test below is dysfunctional since we have moved to StanzaStream. The
|
// The test below is dysfunctional since we have moved to StanzaStream. The
|
||||||
// StanzaStream will attempt to connect to foo@bar indefinitely.
|
// StanzaStream will attempt to connect to foo@bar indefinitely.
|
||||||
// Keeping it here as inspiration for future integration tests.
|
// Keeping it here as inspiration for future integration tests.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue