lib.rs

 1// Copyright (c) 2019 Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
 2//
 3// This Source Code Form is subject to the terms of the Mozilla Public
 4// License, v. 2.0. If a copy of the MPL was not distributed with this
 5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
 6
 7#![deny(bare_trait_objects)]
 8#![cfg_attr(docsrs, feature(doc_auto_cfg))]
 9
10pub use tokio_xmpp;
11pub use tokio_xmpp::jid;
12pub use tokio_xmpp::minidom;
13pub use tokio_xmpp::parsers;
14#[macro_use]
15extern crate log;
16
17pub mod agent;
18pub mod builder;
19pub mod delay;
20pub mod disco;
21pub mod event;
22pub mod event_loop;
23pub mod feature;
24pub mod iq;
25pub mod message;
26pub mod muc;
27pub mod presence;
28pub mod pubsub;
29pub mod upload;
30
31// Module re-exports
32pub use agent::Agent;
33pub use builder::{ClientBuilder, ClientType};
34pub use event::Event;
35pub use feature::ClientFeature;
36
37pub type Error = tokio_xmpp::Error;
38pub type Id = Option<String>;
39pub type RoomNick = String;
40
41// The test below is dysfunctional since we have moved to StanzaStream. The
42// StanzaStream will attempt to connect to foo@bar indefinitely.
43// Keeping it here as inspiration for future integration tests.
44/*
45#[cfg(all(test, any(feature = "starttls-rust", feature = "starttls-native")))]
46mod tests {
47    use super::jid::BareJid;
48    use super::{ClientBuilder, ClientFeature, ClientType, Event};
49    use std::str::FromStr;
50    use tokio_xmpp::Client as TokioXmppClient;
51
52    #[tokio::test]
53    async fn test_simple() {
54        let jid = BareJid::from_str("foo@bar").unwrap();
55
56        let client = TokioXmppClient::new(jid.clone(), "meh");
57
58        // Client instance
59        let client_builder = ClientBuilder::new(jid, "meh")
60            .set_client(ClientType::Bot, "xmpp-rs")
61            .set_website("https://gitlab.com/xmpp-rs/xmpp-rs")
62            .set_default_nick("bot")
63            .enable_feature(ClientFeature::ContactList);
64
65        #[cfg(feature = "avatars")]
66        let client_builder = client_builder.enable_feature(ClientFeature::Avatars);
67
68        let mut agent = client_builder.build_impl(client);
69
70        loop {
71            let events = agent.wait_for_events().await;
72            assert!(match events[0] {
73                Event::Disconnected(_) => true,
74                _ => false,
75            });
76            assert_eq!(events.len(), 1);
77            break;
78        }
79    }
80}
81*/