1//! A crate parsing common XMPP elements into Rust structures.
2//!
3//! Each module implements the `TryFrom<&minidom::Element>` trait, which takes
4//! a minidom `Element` reference and returns a `Result`.
5//!
6//! Parsed structs can then be manipulated manually, and must be serialised
7//! back before being sent over the wire.
8
9// Copyright (c) 2017 Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
10//
11// This Source Code Form is subject to the terms of the Mozilla Public
12// License, v. 2.0. If a copy of the MPL was not distributed with this
13// file, You can obtain one at http://mozilla.org/MPL/2.0/.
14
15#![feature(try_from)]
16
17extern crate minidom;
18extern crate jid;
19extern crate base64;
20extern crate digest;
21extern crate sha_1;
22extern crate sha2;
23extern crate sha3;
24extern crate blake2;
25extern crate chrono;
26
27macro_rules! get_attr {
28 ($elem:ident, $attr:tt, $type:tt) => (
29 get_attr!($elem, $attr, $type, value, value.parse()?)
30 );
31 ($elem:ident, $attr:tt, optional, $value:ident, $func:expr) => (
32 match $elem.attr($attr) {
33 Some($value) => Some($func),
34 None => None,
35 }
36 );
37 ($elem:ident, $attr:tt, required, $value:ident, $func:expr) => (
38 match $elem.attr($attr) {
39 Some($value) => $func,
40 None => return Err(Error::ParseError(concat!("Required attribute '", $attr, "' missing."))),
41 }
42 );
43 ($elem:ident, $attr:tt, default, $value:ident, $func:expr) => (
44 match $elem.attr($attr) {
45 Some($value) => $func,
46 None => Default::default(),
47 }
48 );
49}
50
51/// Error type returned by every parser on failure.
52pub mod error;
53/// XML namespace definitions used through XMPP.
54pub mod ns;
55
56/// RFC 6120: Extensible Messaging and Presence Protocol (XMPP): Core
57pub mod message;
58/// RFC 6120: Extensible Messaging and Presence Protocol (XMPP): Core
59pub mod presence;
60/// RFC 6120: Extensible Messaging and Presence Protocol (XMPP): Core
61pub mod iq;
62/// RFC 6120: Extensible Messaging and Presence Protocol (XMPP): Core
63pub mod stanza_error;
64
65/// XEP-0004: Data Forms
66pub mod data_forms;
67
68/// XEP-0030: Service Discovery
69pub mod disco;
70
71/// XEP-0047: In-Band Bytestreams
72pub mod ibb;
73
74/// XEP-0059: Result Set Management
75pub mod rsm;
76
77/// XEP-0085: Chat State Notifications
78pub mod chatstates;
79
80/// XEP-0115: Entity Capabilities
81pub mod caps;
82
83/// XEP-0166: Jingle
84pub mod jingle;
85
86/// XEP-0184: Message Delivery Receipts
87pub mod receipts;
88
89/// XEP-0199: XMPP Ping
90pub mod ping;
91
92/// XEP-0203: Delayed Delivery
93pub mod delay;
94
95/// XEP-0221: Data Forms Media Element
96pub mod media_element;
97
98/// XEP-0224: Attention
99pub mod attention;
100
101/// XEP-0234: Jingle File Transfer
102pub mod jingle_ft;
103
104/// XEP-0260: Jingle SOCKS5 Bytestreams Transport Method
105pub mod jingle_s5b;
106
107/// XEP-0261: Jingle In-Band Bytestreams Transport Method
108pub mod jingle_ibb;
109
110/// XEP-0297: Stanza Forwarding
111pub mod forwarding;
112
113/// XEP-0300: Use of Cryptographic Hash Functions in XMPP
114pub mod hashes;
115
116/// XEP-0308: Last Message Correction
117pub mod message_correct;
118
119/// XEP-0313: Message Archive Management
120pub mod mam;
121
122/// XEP-0319: Last User Interaction in Presence
123pub mod idle;
124
125/// XEP-0359: Unique and Stable Stanza IDs
126pub mod stanza_id;
127
128/// XEP-0380: Explicit Message Encryption
129pub mod eme;
130
131/// XEP-0390: Entity Capabilities 2.0
132pub mod ecaps2;