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