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