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