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 sha2;
22extern crate sha3;
23extern crate blake2;
24
25macro_rules! get_attr {
26 ($elem:ident, $attr:tt, optional, $value:ident, $func:expr) => (
27 match $elem.attr($attr) {
28 Some($value) => Some($func),
29 None => None,
30 }
31 );
32 ($elem:ident, $attr:tt, required, $value:ident, $func:expr) => (
33 match $elem.attr($attr) {
34 Some($value) => $func,
35 None => return Err(Error::ParseError(concat!("Required attribute '", $attr, "' missing."))),
36 }
37 );
38 ($elem:ident, $attr:tt, default, $value:ident, $func:expr) => (
39 match $elem.attr($attr) {
40 Some($value) => $func,
41 None => Default::default(),
42 }
43 );
44}
45
46/// Error type returned by every parser on failure.
47pub mod error;
48/// XML namespace definitions used through XMPP.
49pub mod ns;
50
51/// RFC 6120: Extensible Messaging and Presence Protocol (XMPP): Core
52pub mod message;
53/// RFC 6120: Extensible Messaging and Presence Protocol (XMPP): Core
54pub mod presence;
55/// RFC 6120: Extensible Messaging and Presence Protocol (XMPP): Core
56pub mod iq;
57/// RFC 6120: Extensible Messaging and Presence Protocol (XMPP): Core
58pub mod stanza_error;
59
60/// XEP-0004: Data Forms
61pub mod data_forms;
62
63/// XEP-0030: Service Discovery
64pub mod disco;
65
66/// XEP-0047: In-Band Bytestreams
67pub mod ibb;
68
69/// XEP-0059: Result Set Management
70pub mod rsm;
71
72/// XEP-0085: Chat State Notifications
73pub mod chatstates;
74
75/// XEP-0166: Jingle
76pub mod jingle;
77
78/// XEP-0184: Message Delivery Receipts
79pub mod receipts;
80
81/// XEP-0199: XMPP Ping
82pub mod ping;
83
84/// XEP-0203: Delayed Delivery
85pub mod delay;
86
87/// XEP-0221: Data Forms Media Element
88pub mod media_element;
89
90/// XEP-0224: Attention
91pub mod attention;
92
93/// XEP-0234: Jingle File Transfer
94pub mod jingle_ft;
95
96/// XEP-0260: Jingle SOCKS5 Bytestreams Transport Method
97pub mod jingle_s5b;
98
99/// XEP-0261: Jingle In-Band Bytestreams Transport Method
100pub mod jingle_ibb;
101
102/// XEP-0297: Stanza Forwarding
103pub mod forwarding;
104
105/// XEP-0300: Use of Cryptographic Hash Functions in XMPP
106pub mod hashes;
107
108/// XEP-0308: Last Message Correction
109pub mod message_correct;
110
111/// XEP-0313: Message Archive Management
112pub mod mam;
113
114/// XEP-0359: Unique and Stable Stanza IDs
115pub mod stanza_id;
116
117/// XEP-0380: Explicit Message Encryption
118pub mod eme;
119
120/// XEP-0390: Entity Capabilities 2.0
121pub mod ecaps2;