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/// RFC 6121: Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence
66pub mod roster;
67
68/// XEP-0004: Data Forms
69pub mod data_forms;
70
71/// XEP-0030: Service Discovery
72pub mod disco;
73
74/// XEP-0047: In-Band Bytestreams
75pub mod ibb;
76
77/// XEP-0059: Result Set Management
78pub mod rsm;
79
80/// XEP-0085: Chat State Notifications
81pub mod chatstates;
82
83/// XEP-0115: Entity Capabilities
84pub mod caps;
85
86/// XEP-0166: Jingle
87pub mod jingle;
88
89/// XEP-0184: Message Delivery Receipts
90pub mod receipts;
91
92/// XEP-0199: XMPP Ping
93pub mod ping;
94
95/// XEP-0203: Delayed Delivery
96pub mod delay;
97
98/// XEP-0221: Data Forms Media Element
99pub mod media_element;
100
101/// XEP-0224: Attention
102pub mod attention;
103
104/// XEP-0234: Jingle File Transfer
105pub mod jingle_ft;
106
107/// XEP-0260: Jingle SOCKS5 Bytestreams Transport Method
108pub mod jingle_s5b;
109
110/// XEP-0261: Jingle In-Band Bytestreams Transport Method
111pub mod jingle_ibb;
112
113/// XEP-0297: Stanza Forwarding
114pub mod forwarding;
115
116/// XEP-0300: Use of Cryptographic Hash Functions in XMPP
117pub mod hashes;
118
119/// XEP-0308: Last Message Correction
120pub mod message_correct;
121
122/// XEP-0313: Message Archive Management
123pub mod mam;
124
125/// XEP-0319: Last User Interaction in Presence
126pub mod idle;
127
128/// XEP-0359: Unique and Stable Stanza IDs
129pub mod stanza_id;
130
131/// XEP-0380: Explicit Message Encryption
132pub mod eme;
133
134/// XEP-0390: Entity Capabilities 2.0
135pub mod ecaps2;