Cargo.toml 🔗
@@ -11,6 +11,7 @@ repository = "https://hg.linkmauve.fr/xmpp-parsers"
keywords = ["xmpp", "xml"]
categories = ["parsing", "network-programming"]
license = "MPL-2.0"
+edition = "2018"
[dependencies]
minidom = "0.9.1"
Emmanuel Gil Peyrot created
Cargo.toml | 1
src/attention.rs | 4
src/bind.rs | 6 +-
src/blocking.rs | 6 +-
src/bookmarks.rs | 2
src/caps.rs | 14 +++---
src/chatstates.rs | 6 +-
src/component.rs | 2
src/data_forms.rs | 6 +-
src/date.rs | 2
src/delay.rs | 10 ++--
src/disco.rs | 10 ++--
src/ecaps2.rs | 12 ++--
src/eme.rs | 4
src/forwarding.rs | 6 +-
src/hashes.rs | 4
src/helpers.rs | 2
src/ibb.rs | 6 +-
src/ibr.rs | 10 ++--
src/idle.rs | 6 +-
src/iq.rs | 12 ++--
src/jingle.rs | 6 +-
src/jingle_ft.rs | 12 ++--
src/jingle_ibb.rs | 4
src/jingle_message.rs | 6 +-
src/jingle_s5b.rs | 6 +-
src/macros.rs | 90 ++++++++++++++++++++++----------------------
src/mam.rs | 16 +++---
src/media_element.rs | 6 +-
src/message.rs | 6 +-
src/message_correct.rs | 4
src/muc/muc.rs | 8 +-
src/muc/user.rs | 6 +-
src/nick.rs | 2
src/ping.rs | 4
src/presence.rs | 6 +-
src/pubsub/event.rs | 12 ++--
src/pubsub/pubsub.rs | 12 ++--
src/receipts.rs | 4
src/roster.rs | 6 +-
src/rsm.rs | 6 +-
src/sasl.rs | 6 +-
src/sm.rs | 2
src/stanza_error.rs | 8 +-
src/stanza_id.rs | 4
src/version.rs | 4
46 files changed, 189 insertions(+), 188 deletions(-)
@@ -11,6 +11,7 @@ repository = "https://hg.linkmauve.fr/xmpp-parsers"
keywords = ["xmpp", "xml"]
categories = ["parsing", "network-programming"]
license = "MPL-2.0"
+edition = "2018"
[dependencies]
minidom = "0.9.1"
@@ -4,7 +4,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
-use message::MessagePayload;
+use crate::message::MessagePayload;
generate_empty_element!(
/// Requests the attention of the recipient.
@@ -18,7 +18,7 @@ mod tests {
use super::*;
use try_from::TryFrom;
use minidom::Element;
- use error::Error;
+ use crate::error::Error;
#[test]
fn test_size() {
@@ -9,10 +9,10 @@ use try_from::TryFrom;
use minidom::Element;
-use error::Error;
+use crate::error::Error;
use jid::Jid;
-use ns;
-use iq::{IqSetPayload, IqResultPayload};
+use crate::ns;
+use crate::iq::{IqSetPayload, IqResultPayload};
/// The request for resource binding, which is the process by which a client
/// can obtain a full JID and start exchanging on the XMPP network.
@@ -9,10 +9,10 @@ use try_from::TryFrom;
use jid::Jid;
use minidom::Element;
-use error::Error;
+use crate::error::Error;
-use ns;
-use iq::{IqGetPayload, IqSetPayload, IqResultPayload};
+use crate::ns;
+use crate::iq::{IqGetPayload, IqSetPayload, IqResultPayload};
generate_empty_element!(
/// The element requesting the blocklist, the result iq will contain a
@@ -72,7 +72,7 @@ mod tests {
use super::*;
use try_from::TryFrom;
use minidom::Element;
- use compare_elements::NamespaceAwareCompare;
+ use crate::compare_elements::NamespaceAwareCompare;
#[cfg(target_pointer_width = "32")]
#[test]
@@ -6,14 +6,14 @@
use try_from::TryFrom;
-use presence::PresencePayload;
-use disco::{Feature, Identity, DiscoInfoResult, DiscoInfoQuery};
-use data_forms::DataForm;
-use hashes::{Hash, Algo};
+use crate::presence::PresencePayload;
+use crate::disco::{Feature, Identity, DiscoInfoResult, DiscoInfoQuery};
+use crate::data_forms::DataForm;
+use crate::hashes::{Hash, Algo};
use minidom::Element;
-use error::Error;
-use ns;
+use crate::error::Error;
+use crate::ns;
use base64;
use sha1::Sha1;
@@ -208,7 +208,7 @@ pub fn query_caps(caps: Caps) -> DiscoInfoQuery {
#[cfg(test)]
mod tests {
use super::*;
- use caps;
+ use crate::caps;
use base64;
#[cfg(target_pointer_width = "32")]
@@ -4,7 +4,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
-use message::MessagePayload;
+use crate::message::MessagePayload;
generate_element_enum!(
/// Enum representing chatstate elements part of the
@@ -34,8 +34,8 @@ mod tests {
use super::*;
use try_from::TryFrom;
use minidom::Element;
- use error::Error;
- use ns;
+ use crate::error::Error;
+ use crate::ns;
#[test]
fn test_size() {
@@ -4,7 +4,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
-use helpers::PlainText;
+use crate::helpers::PlainText;
use sha1::Sha1;
use digest::Digest;
@@ -8,10 +8,10 @@ use try_from::TryFrom;
use minidom::Element;
-use error::Error;
-use ns;
+use crate::error::Error;
+use crate::ns;
-use media_element::MediaElement;
+use crate::media_element::MediaElement;
generate_element!(
/// Represents one of the possible values for a list- field.
@@ -9,7 +9,7 @@ use std::str::FromStr;
use minidom::{IntoAttributeValue, IntoElements, ElementEmitter};
use chrono::{DateTime as ChronoDateTime, FixedOffset};
-use error::Error;
+use crate::error::Error;
/// Implements the DateTime profile of XEP-0082, which represents a
/// non-recurring moment in time, with an accuracy of seconds or fraction of
@@ -4,13 +4,13 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
-use message::MessagePayload;
-use presence::PresencePayload;
-use date::DateTime;
+use crate::message::MessagePayload;
+use crate::presence::PresencePayload;
+use crate::date::DateTime;
use jid::Jid;
-use helpers::PlainText;
+use crate::helpers::PlainText;
generate_element!(
/// Notes when and by whom a message got stored for later delivery.
@@ -36,7 +36,7 @@ mod tests {
use super::*;
use try_from::TryFrom;
use minidom::Element;
- use error::Error;
+ use crate::error::Error;
use std::str::FromStr;
#[cfg(target_pointer_width = "32")]
@@ -9,11 +9,11 @@ use try_from::TryFrom;
use minidom::Element;
use jid::Jid;
-use error::Error;
-use ns;
+use crate::error::Error;
+use crate::ns;
-use iq::{IqGetPayload, IqResultPayload};
-use data_forms::{DataForm, DataFormType};
+use crate::iq::{IqGetPayload, IqResultPayload};
+use crate::data_forms::{DataForm, DataFormType};
generate_element!(
/// Structure representing a `<query xmlns='http://jabber.org/protocol/disco#info'/>` element.
@@ -221,7 +221,7 @@ impl IqResultPayload for DiscoItemsResult {}
#[cfg(test)]
mod tests {
use super::*;
- use compare_elements::NamespaceAwareCompare;
+ use crate::compare_elements::NamespaceAwareCompare;
use std::str::FromStr;
#[cfg(target_pointer_width = "32")]
@@ -4,12 +4,12 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
-use presence::PresencePayload;
-use disco::{Feature, Identity, DiscoInfoResult, DiscoInfoQuery};
-use data_forms::DataForm;
-use hashes::{Hash, Algo};
+use crate::presence::PresencePayload;
+use crate::disco::{Feature, Identity, DiscoInfoResult, DiscoInfoQuery};
+use crate::data_forms::DataForm;
+use crate::hashes::{Hash, Algo};
-use ns;
+use crate::ns;
use base64;
use sha2::{Sha256, Sha512};
@@ -150,7 +150,7 @@ mod tests {
use super::*;
use try_from::TryFrom;
use minidom::Element;
- use error::Error;
+ use crate::error::Error;
#[cfg(target_pointer_width = "32")]
#[test]
@@ -4,7 +4,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
-use message::MessagePayload;
+use crate::message::MessagePayload;
generate_element!(
/// Structure representing an `<encryption xmlns='urn:xmpp:eme:0'/>` element.
@@ -26,7 +26,7 @@ mod tests {
use super::*;
use try_from::TryFrom;
use minidom::Element;
- use error::Error;
+ use crate::error::Error;
#[cfg(target_pointer_width = "32")]
#[test]
@@ -4,8 +4,8 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
-use delay::Delay;
-use message::Message;
+use crate::delay::Delay;
+use crate::message::Message;
generate_element!(
/// Contains a forwarded stanza, either standalone or part of another
@@ -28,7 +28,7 @@ mod tests {
use super::*;
use try_from::TryFrom;
use minidom::Element;
- use error::Error;
+ use crate::error::Error;
#[cfg(target_pointer_width = "32")]
#[test]
@@ -8,9 +8,9 @@ use std::str::FromStr;
use minidom::IntoAttributeValue;
-use error::Error;
+use crate::error::Error;
-use helpers::Base64;
+use crate::helpers::Base64;
use base64;
/// List of the algorithms we support, or Unknown.
@@ -5,7 +5,7 @@
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
use base64;
-use error::Error;
+use crate::error::Error;
/// Codec for plain text content.
pub struct PlainText;
@@ -4,8 +4,8 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
-use helpers::Base64;
-use iq::IqSetPayload;
+use crate::helpers::Base64;
+use crate::iq::IqSetPayload;
generate_id!(
/// An identifier matching a stream.
@@ -73,7 +73,7 @@ mod tests {
use super::*;
use try_from::TryFrom;
use minidom::Element;
- use error::Error;
+ use crate::error::Error;
use std::error::Error as StdError;
#[cfg(target_pointer_width = "32")]
@@ -9,12 +9,12 @@ use try_from::TryFrom;
use minidom::Element;
-use error::Error;
+use crate::error::Error;
-use iq::{IqGetPayload, IqSetPayload, IqResultPayload};
-use data_forms::DataForm;
+use crate::iq::{IqGetPayload, IqSetPayload, IqResultPayload};
+use crate::data_forms::DataForm;
-use ns;
+use crate::ns;
/// Query for registering against a service.
#[derive(Debug, Clone)]
@@ -94,7 +94,7 @@ impl From<Query> for Element {
#[cfg(test)]
mod tests {
use super::*;
- use compare_elements::NamespaceAwareCompare;
+ use crate::compare_elements::NamespaceAwareCompare;
#[cfg(target_pointer_width = "32")]
#[test]
@@ -4,8 +4,8 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
-use presence::PresencePayload;
-use date::DateTime;
+use crate::presence::PresencePayload;
+use crate::date::DateTime;
generate_element!(
/// Represents the last time the user interacted with their system.
@@ -23,7 +23,7 @@ mod tests {
use super::*;
use try_from::TryFrom;
use minidom::Element;
- use error::Error;
+ use crate::error::Error;
use std::str::FromStr;
use std::error::Error as StdError;
@@ -12,11 +12,11 @@ use minidom::IntoAttributeValue;
use jid::Jid;
-use error::Error;
+use crate::error::Error;
-use ns;
+use crate::ns;
-use stanza_error::StanzaError;
+use crate::stanza_error::StanzaError;
/// Should be implemented on every known payload of an `<iq type='get'/>`.
pub trait IqGetPayload: TryFrom<Element> + Into<Element> {}
@@ -222,9 +222,9 @@ impl From<Iq> for Element {
#[cfg(test)]
mod tests {
use super::*;
- use stanza_error::{ErrorType, DefinedCondition};
- use compare_elements::NamespaceAwareCompare;
- use disco::DiscoInfoQuery;
+ use crate::stanza_error::{ErrorType, DefinedCondition};
+ use crate::compare_elements::NamespaceAwareCompare;
+ use crate::disco::DiscoInfoQuery;
#[cfg(target_pointer_width = "32")]
#[test]
@@ -10,9 +10,9 @@ use std::str::FromStr;
use minidom::Element;
use jid::Jid;
-use error::Error;
-use ns;
-use iq::IqSetPayload;
+use crate::error::Error;
+use crate::ns;
+use crate::iq::IqSetPayload;
generate_attribute!(
/// The action attribute.
@@ -9,14 +9,14 @@ use std::str::FromStr;
use std::collections::BTreeMap;
-use hashes::Hash;
-use jingle::{Creator, ContentId};
-use date::DateTime;
+use crate::hashes::Hash;
+use crate::jingle::{Creator, ContentId};
+use crate::date::DateTime;
use minidom::Element;
-use error::Error;
-use ns;
+use crate::error::Error;
+use crate::ns;
generate_element!(
/// Represents a range in a file.
@@ -345,7 +345,7 @@ generate_element!(
#[cfg(test)]
mod tests {
use super::*;
- use hashes::Algo;
+ use crate::hashes::Algo;
use base64;
#[cfg(target_pointer_width = "32")]
@@ -4,7 +4,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
-use ibb::{Stanza, StreamId};
+use crate::ibb::{Stanza, StreamId};
generate_element!(
/// Describes an [In-Band Bytestream](https://xmpp.org/extensions/xep-0047.html)
@@ -26,7 +26,7 @@ mod tests {
use super::*;
use try_from::TryFrom;
use minidom::Element;
- use error::Error;
+ use crate::error::Error;
use std::error::Error as StdError;
#[cfg(target_pointer_width = "32")]
@@ -8,11 +8,11 @@ use try_from::TryFrom;
use minidom::Element;
-use error::Error;
+use crate::error::Error;
-use jingle::SessionId;
+use crate::jingle::SessionId;
-use ns;
+use crate::ns;
/// Defines a protocol for broadcasting Jingle requests to all of the clients
/// of a user.
@@ -10,9 +10,9 @@ use std::net::IpAddr;
use minidom::Element;
use jid::Jid;
-use error::Error;
+use crate::error::Error;
-use ns;
+use crate::ns;
generate_attribute!(
/// The type of the connection being proposed by this candidate.
@@ -275,7 +275,7 @@ impl From<Transport> for Element {
mod tests {
use super::*;
use std::str::FromStr;
- use compare_elements::NamespaceAwareCompare;
+ use crate::compare_elements::NamespaceAwareCompare;
#[cfg(target_pointer_width = "32")]
#[test]
@@ -24,7 +24,7 @@ macro_rules! get_attr {
($elem:ident, $attr:tt, required, $value:ident, $func:expr) => (
match $elem.attr($attr) {
Some($value) => $func,
- None => return Err(::error::Error::ParseError(concat!("Required attribute '", $attr, "' missing."))),
+ None => return Err(crate::error::Error::ParseError(concat!("Required attribute '", $attr, "' missing."))),
}
);
($elem:ident, $attr:tt, default, $value:ident, $func:expr) => (
@@ -52,11 +52,11 @@ macro_rules! generate_attribute {
),+
}
impl ::std::str::FromStr for $elem {
- type Err = ::error::Error;
- fn from_str(s: &str) -> Result<$elem, ::error::Error> {
+ type Err = crate::error::Error;
+ fn from_str(s: &str) -> Result<$elem, crate::error::Error> {
Ok(match s {
$($b => $elem::$a),+,
- _ => return Err(::error::Error::ParseError(concat!("Unknown value for '", $name, "' attribute."))),
+ _ => return Err(crate::error::Error::ParseError(concat!("Unknown value for '", $name, "' attribute."))),
})
}
}
@@ -78,11 +78,11 @@ macro_rules! generate_attribute {
),+
}
impl ::std::str::FromStr for $elem {
- type Err = ::error::Error;
- fn from_str(s: &str) -> Result<$elem, ::error::Error> {
+ type Err = crate::error::Error;
+ fn from_str(s: &str) -> Result<$elem, crate::error::Error> {
Ok(match s {
$($b => $elem::$a),+,
- _ => return Err(::error::Error::ParseError(concat!("Unknown value for '", $name, "' attribute."))),
+ _ => return Err(crate::error::Error::ParseError(concat!("Unknown value for '", $name, "' attribute."))),
})
}
}
@@ -111,12 +111,12 @@ macro_rules! generate_attribute {
False,
}
impl ::std::str::FromStr for $elem {
- type Err = ::error::Error;
- fn from_str(s: &str) -> Result<Self, ::error::Error> {
+ type Err = crate::error::Error;
+ fn from_str(s: &str) -> Result<Self, crate::error::Error> {
Ok(match s {
"true" | "1" => $elem::True,
"false" | "0" => $elem::False,
- _ => return Err(::error::Error::ParseError(concat!("Unknown value for '", $name, "' attribute."))),
+ _ => return Err(crate::error::Error::ParseError(concat!("Unknown value for '", $name, "' attribute."))),
})
}
}
@@ -150,14 +150,14 @@ macro_rules! generate_element_enum {
),+
}
impl ::try_from::TryFrom<::minidom::Element> for $elem {
- type Err = ::error::Error;
- fn try_from(elem: ::minidom::Element) -> Result<$elem, ::error::Error> {
+ type Err = crate::error::Error;
+ fn try_from(elem: ::minidom::Element) -> Result<$elem, crate::error::Error> {
check_ns_only!(elem, $name, $ns);
check_no_children!(elem, $name);
check_no_attributes!(elem, $name);
Ok(match elem.name() {
$($enum_name => $elem::$enum,)+
- _ => return Err(::error::Error::ParseError(concat!("This is not a ", $name, " element."))),
+ _ => return Err(crate::error::Error::ParseError(concat!("This is not a ", $name, " element."))),
})
}
}
@@ -165,7 +165,7 @@ macro_rules! generate_element_enum {
fn from(elem: $elem) -> ::minidom::Element {
::minidom::Element::builder(match elem {
$($elem::$enum => $enum_name,)+
- }).ns(::ns::$ns)
+ }).ns(crate::ns::$ns)
.build()
}
}
@@ -186,21 +186,21 @@ macro_rules! generate_attribute_enum {
),+
}
impl ::try_from::TryFrom<::minidom::Element> for $elem {
- type Err = ::error::Error;
- fn try_from(elem: ::minidom::Element) -> Result<$elem, ::error::Error> {
+ type Err = crate::error::Error;
+ fn try_from(elem: ::minidom::Element) -> Result<$elem, crate::error::Error> {
check_ns_only!(elem, $name, $ns);
check_no_children!(elem, $name);
check_no_unknown_attributes!(elem, $name, [$attr]);
Ok(match get_attr!(elem, $attr, required) {
$($enum_name => $elem::$enum,)+
- _ => return Err(::error::Error::ParseError(concat!("Invalid ", $name, " ", $attr, " value."))),
+ _ => return Err(crate::error::Error::ParseError(concat!("Invalid ", $name, " ", $attr, " value."))),
})
}
}
impl From<$elem> for ::minidom::Element {
fn from(elem: $elem) -> ::minidom::Element {
::minidom::Element::builder($name)
- .ns(::ns::$ns)
+ .ns(crate::ns::$ns)
.attr($attr, match elem {
$($elem::$enum => $enum_name,)+
})
@@ -215,16 +215,16 @@ macro_rules! check_self {
check_self!($elem, $name, $ns, $name);
);
($elem:ident, $name:tt, $ns:ident, $pretty_name:tt) => (
- if !$elem.is($name, ::ns::$ns) {
- return Err(::error::Error::ParseError(concat!("This is not a ", $pretty_name, " element.")));
+ if !$elem.is($name, crate::ns::$ns) {
+ return Err(crate::error::Error::ParseError(concat!("This is not a ", $pretty_name, " element.")));
}
);
}
macro_rules! check_ns_only {
($elem:ident, $name:tt, $ns:ident) => (
- if !$elem.has_ns(::ns::$ns) {
- return Err(::error::Error::ParseError(concat!("This is not a ", $name, " element.")));
+ if !$elem.has_ns(crate::ns::$ns) {
+ return Err(crate::error::Error::ParseError(concat!("This is not a ", $name, " element.")));
}
);
}
@@ -232,7 +232,7 @@ macro_rules! check_ns_only {
macro_rules! check_no_children {
($elem:ident, $name:tt) => (
for _ in $elem.children() {
- return Err(::error::Error::ParseError(concat!("Unknown child in ", $name, " element.")));
+ return Err(crate::error::Error::ParseError(concat!("Unknown child in ", $name, " element.")));
}
);
}
@@ -240,7 +240,7 @@ macro_rules! check_no_children {
macro_rules! check_no_attributes {
($elem:ident, $name:tt) => (
for _ in $elem.attrs() {
- return Err(::error::Error::ParseError(concat!("Unknown attribute in ", $name, " element.")));
+ return Err(crate::error::Error::ParseError(concat!("Unknown attribute in ", $name, " element.")));
}
);
}
@@ -253,7 +253,7 @@ macro_rules! check_no_unknown_attributes {
continue;
}
)*
- return Err(::error::Error::ParseError(concat!("Unknown attribute in ", $name, " element.")));
+ return Err(crate::error::Error::ParseError(concat!("Unknown attribute in ", $name, " element.")));
}
);
}
@@ -265,9 +265,9 @@ macro_rules! generate_empty_element {
pub struct $elem;
impl ::try_from::TryFrom<::minidom::Element> for $elem {
- type Err = ::error::Error;
+ type Err = crate::error::Error;
- fn try_from(elem: ::minidom::Element) -> Result<$elem, ::error::Error> {
+ fn try_from(elem: ::minidom::Element) -> Result<$elem, crate::error::Error> {
check_self!(elem, $name, $ns);
check_no_children!(elem, $name);
check_no_attributes!(elem, $name);
@@ -278,7 +278,7 @@ macro_rules! generate_empty_element {
impl From<$elem> for ::minidom::Element {
fn from(_: $elem) -> ::minidom::Element {
::minidom::Element::builder($name)
- .ns(::ns::$ns)
+ .ns(crate::ns::$ns)
.build()
}
}
@@ -291,8 +291,8 @@ macro_rules! generate_id {
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct $elem(pub String);
impl ::std::str::FromStr for $elem {
- type Err = ::error::Error;
- fn from_str(s: &str) -> Result<$elem, ::error::Error> {
+ type Err = crate::error::Error;
+ fn from_str(s: &str) -> Result<$elem, crate::error::Error> {
// TODO: add a way to parse that differently when needed.
Ok($elem(String::from(s)))
}
@@ -311,15 +311,15 @@ macro_rules! generate_elem_id {
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct $elem(pub String);
impl ::std::str::FromStr for $elem {
- type Err = ::error::Error;
- fn from_str(s: &str) -> Result<$elem, ::error::Error> {
+ type Err = crate::error::Error;
+ fn from_str(s: &str) -> Result<$elem, crate::error::Error> {
// TODO: add a way to parse that differently when needed.
Ok($elem(String::from(s)))
}
}
impl ::try_from::TryFrom<::minidom::Element> for $elem {
- type Err = ::error::Error;
- fn try_from(elem: ::minidom::Element) -> Result<$elem, ::error::Error> {
+ type Err = crate::error::Error;
+ fn try_from(elem: ::minidom::Element) -> Result<$elem, crate::error::Error> {
check_self!(elem, $name, $ns);
check_no_children!(elem, $name);
check_no_attributes!(elem, $name);
@@ -330,7 +330,7 @@ macro_rules! generate_elem_id {
impl From<$elem> for ::minidom::Element {
fn from(elem: $elem) -> ::minidom::Element {
::minidom::Element::builder($name)
- .ns(::ns::$ns)
+ .ns(crate::ns::$ns)
.append(elem.0)
.build()
}
@@ -380,13 +380,13 @@ macro_rules! do_parse_elem {
);
($temp:ident: Option = $constructor:ident => $elem:ident, $name:tt, $parent_name:tt) => (
if $temp.is_some() {
- return Err(::error::Error::ParseError(concat!("Element ", $parent_name, " must not have more than one ", $name, " child.")));
+ return Err(crate::error::Error::ParseError(concat!("Element ", $parent_name, " must not have more than one ", $name, " child.")));
}
$temp = Some(do_parse!($elem, $constructor));
);
($temp:ident: Required = $constructor:ident => $elem:ident, $name:tt, $parent_name:tt) => (
if $temp.is_some() {
- return Err(::error::Error::ParseError(concat!("Element ", $parent_name, " must not have more than one ", $name, " child.")));
+ return Err(crate::error::Error::ParseError(concat!("Element ", $parent_name, " must not have more than one ", $name, " child.")));
}
$temp = Some(do_parse!($elem, $constructor));
);
@@ -400,21 +400,21 @@ macro_rules! finish_parse_elem {
$temp
);
($temp:ident: Required = $name:tt, $parent_name:tt) => (
- $temp.ok_or(::error::Error::ParseError(concat!("Missing child ", $name, " in ", $parent_name, " element.")))?
+ $temp.ok_or(crate::error::Error::ParseError(concat!("Missing child ", $name, " in ", $parent_name, " element.")))?
);
}
macro_rules! generate_serialiser {
($parent:ident, $elem:ident, Required, String, ($name:tt, $ns:ident)) => (
::minidom::Element::builder($name)
- .ns(::ns::$ns)
+ .ns(crate::ns::$ns)
.append($parent.$elem)
.build()
);
($parent:ident, $elem:ident, Option, String, ($name:tt, $ns:ident)) => (
$parent.$elem.map(|elem|
::minidom::Element::builder($name)
- .ns(::ns::$ns)
+ .ns(crate::ns::$ns)
.append(elem)
.build())
);
@@ -461,9 +461,9 @@ macro_rules! generate_element {
}
impl ::try_from::TryFrom<::minidom::Element> for $elem {
- type Err = ::error::Error;
+ type Err = crate::error::Error;
- fn try_from(elem: ::minidom::Element) -> Result<$elem, ::error::Error> {
+ fn try_from(elem: ::minidom::Element) -> Result<$elem, crate::error::Error> {
check_self!(elem, $name, $ns);
check_no_unknown_attributes!(elem, $name, [$($attr_name),*]);
$(
@@ -471,12 +471,12 @@ macro_rules! generate_element {
)*
for _child in elem.children() {
$(
- if _child.is($child_name, ::ns::$child_ns) {
+ if _child.is($child_name, crate::ns::$child_ns) {
do_parse_elem!($child_ident: $coucou = $child_constructor => _child, $child_name, $name);
continue;
}
)*
- return Err(::error::Error::ParseError(concat!("Unknown child in ", $name, " element.")));
+ return Err(crate::error::Error::ParseError(concat!("Unknown child in ", $name, " element.")));
}
Ok($elem {
$(
@@ -495,7 +495,7 @@ macro_rules! generate_element {
impl From<$elem> for ::minidom::Element {
fn from(elem: $elem) -> ::minidom::Element {
::minidom::Element::builder($name)
- .ns(::ns::$ns)
+ .ns(crate::ns::$ns)
$(
.attr($attr_name, elem.$attr)
)*
@@ -9,16 +9,16 @@ use try_from::TryFrom;
use minidom::Element;
use jid::Jid;
-use error::Error;
+use crate::error::Error;
-use message::MessagePayload;
-use iq::{IqGetPayload, IqSetPayload, IqResultPayload};
-use data_forms::DataForm;
-use rsm::{SetQuery, SetResult};
-use forwarding::Forwarded;
-use pubsub::NodeName;
+use crate::message::MessagePayload;
+use crate::iq::{IqGetPayload, IqSetPayload, IqResultPayload};
+use crate::data_forms::DataForm;
+use crate::rsm::{SetQuery, SetResult};
+use crate::forwarding::Forwarded;
+use crate::pubsub::NodeName;
-use ns;
+use crate::ns;
generate_id!(
/// An identifier matching a result message to the query requesting it.
@@ -4,7 +4,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
-use helpers::TrimmedPlainText;
+use crate::helpers::TrimmedPlainText;
generate_element!(
/// Represents an URI used in a media element.
@@ -47,8 +47,8 @@ mod tests {
use super::*;
use try_from::TryFrom;
use minidom::Element;
- use error::Error;
- use data_forms::DataForm;
+ use crate::error::Error;
+ use crate::data_forms::DataForm;
use std::error::Error as StdError;
#[cfg(target_pointer_width = "32")]
@@ -11,9 +11,9 @@ use minidom::Element;
use jid::Jid;
-use error::Error;
+use crate::error::Error;
-use ns;
+use crate::ns;
/// Should be implemented on every known payload of a `<message/>`.
pub trait MessagePayload: TryFrom<Element> + Into<Element> {}
@@ -232,7 +232,7 @@ impl From<Message> for Element {
mod tests {
use super::*;
use std::str::FromStr;
- use compare_elements::NamespaceAwareCompare;
+ use crate::compare_elements::NamespaceAwareCompare;
#[cfg(target_pointer_width = "32")]
#[test]
@@ -4,7 +4,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
-use message::MessagePayload;
+use crate::message::MessagePayload;
generate_element!(
/// Defines that the message containing this payload should replace a
@@ -23,7 +23,7 @@ mod tests {
use super::*;
use try_from::TryFrom;
use minidom::Element;
- use error::Error;
+ use crate::error::Error;
#[cfg(target_pointer_width = "32")]
#[test]
@@ -5,8 +5,8 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
-use presence::PresencePayload;
-use date::DateTime;
+use crate::presence::PresencePayload;
+use crate::date::DateTime;
generate_element!(
/// Represents the query for messages before our join.
@@ -104,9 +104,9 @@ mod tests {
use super::*;
use try_from::TryFrom;
use minidom::Element;
- use error::Error;
+ use crate::error::Error;
use std::str::FromStr;
- use compare_elements::NamespaceAwareCompare;
+ use crate::compare_elements::NamespaceAwareCompare;
#[test]
fn test_muc_simple() {
@@ -11,9 +11,9 @@ use minidom::Element;
use jid::Jid;
-use error::Error;
+use crate::error::Error;
-use ns;
+use crate::ns;
generate_attribute_enum!(
/// Lists all of the possible status codes used in MUC presences.
@@ -238,7 +238,7 @@ generate_element!(
mod tests {
use super::*;
use std::error::Error as StdError;
- use compare_elements::NamespaceAwareCompare;
+ use crate::compare_elements::NamespaceAwareCompare;
#[test]
fn test_simple() {
@@ -14,7 +14,7 @@ mod tests {
use super::*;
use try_from::TryFrom;
use minidom::Element;
- use error::Error;
+ use crate::error::Error;
#[cfg(target_pointer_width = "32")]
#[test]
@@ -5,7 +5,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
-use iq::IqGetPayload;
+use crate::iq::IqGetPayload;
generate_empty_element!(
/// Represents a ping to the recipient, which must be answered with an
@@ -20,7 +20,7 @@ mod tests {
use super::*;
use try_from::TryFrom;
use minidom::Element;
- use error::Error;
+ use crate::error::Error;
#[test]
fn test_size() {
@@ -13,9 +13,9 @@ use minidom::{Element, IntoElements, IntoAttributeValue, ElementEmitter};
use jid::Jid;
-use error::Error;
+use crate::error::Error;
-use ns;
+use crate::ns;
/// Should be implemented on every known payload of a `<presence/>`.
pub trait PresencePayload: TryFrom<Element> + Into<Element> {}
@@ -331,7 +331,7 @@ impl From<Presence> for Element {
#[cfg(test)]
mod tests {
use super::*;
- use compare_elements::NamespaceAwareCompare;
+ use crate::compare_elements::NamespaceAwareCompare;
#[cfg(target_pointer_width = "32")]
#[test]
@@ -8,15 +8,15 @@ use try_from::TryFrom;
use minidom::Element;
use jid::Jid;
-use date::DateTime;
+use crate::date::DateTime;
-use error::Error;
+use crate::error::Error;
-use ns;
+use crate::ns;
-use data_forms::DataForm;
+use crate::data_forms::DataForm;
-use pubsub::{NodeName, ItemId, Subscription, SubscriptionId};
+use crate::pubsub::{NodeName, ItemId, Subscription, SubscriptionId};
/// One PubSub item from a node.
#[derive(Debug, Clone)]
@@ -288,7 +288,7 @@ impl From<PubSubEvent> for Element {
mod tests {
use super::*;
use std::str::FromStr;
- use compare_elements::NamespaceAwareCompare;
+ use crate::compare_elements::NamespaceAwareCompare;
#[test]
fn missing_items() {
@@ -9,14 +9,14 @@ use try_from::TryFrom;
use minidom::Element;
use jid::Jid;
-use error::Error;
+use crate::error::Error;
-use ns;
+use crate::ns;
-use iq::{IqGetPayload, IqSetPayload, IqResultPayload};
-use data_forms::DataForm;
+use crate::iq::{IqGetPayload, IqSetPayload, IqResultPayload};
+use crate::data_forms::DataForm;
-use pubsub::{NodeName, ItemId, Subscription, SubscriptionId};
+use crate::pubsub::{NodeName, ItemId, Subscription, SubscriptionId};
// TODO: a better solution would be to split this into a query and a result elements, like for
// XEP-0030.
@@ -497,7 +497,7 @@ impl From<PubSub> for Element {
#[cfg(test)]
mod tests {
use super::*;
- use compare_elements::NamespaceAwareCompare;
+ use crate::compare_elements::NamespaceAwareCompare;
#[test]
fn create() {
@@ -4,7 +4,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
-use message::MessagePayload;
+use crate::message::MessagePayload;
generate_empty_element!(
/// Requests that this message is acked by the final recipient once
@@ -31,7 +31,7 @@ mod tests {
use super::*;
use try_from::TryFrom;
use minidom::Element;
- use ns;
+ use crate::ns;
#[cfg(target_pointer_width = "32")]
#[test]
@@ -5,7 +5,7 @@
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
use jid::Jid;
-use iq::{IqGetPayload, IqSetPayload, IqResultPayload};
+use crate::iq::{IqGetPayload, IqSetPayload, IqResultPayload};
generate_elem_id!(
/// Represents a group a contact is part of.
@@ -81,9 +81,9 @@ mod tests {
use super::*;
use try_from::TryFrom;
use minidom::Element;
- use error::Error;
+ use crate::error::Error;
use std::str::FromStr;
- use compare_elements::NamespaceAwareCompare;
+ use crate::compare_elements::NamespaceAwareCompare;
#[cfg(target_pointer_width = "32")]
#[test]
@@ -8,9 +8,9 @@ use try_from::TryFrom;
use minidom::Element;
-use error::Error;
+use crate::error::Error;
-use ns;
+use crate::ns;
/// Requests paging through a potentially big set of items (represented by an
/// UID).
@@ -156,7 +156,7 @@ impl From<SetResult> for Element {
#[cfg(test)]
mod tests {
use super::*;
- use compare_elements::NamespaceAwareCompare;
+ use crate::compare_elements::NamespaceAwareCompare;
#[cfg(target_pointer_width = "32")]
#[test]
@@ -8,10 +8,10 @@ use std::collections::BTreeMap;
use try_from::TryFrom;
use minidom::Element;
-use error::Error;
-use ns;
+use crate::error::Error;
+use crate::ns;
-use helpers::Base64;
+use crate::helpers::Base64;
generate_attribute!(
/// The list of available SASL mechanisms.
@@ -4,7 +4,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
-use stanza_error::DefinedCondition;
+use crate::stanza_error::DefinedCondition;
generate_element!(
/// Acknowledgement of the currently received stanzas.
@@ -9,11 +9,11 @@ use std::collections::BTreeMap;
use minidom::Element;
-use message::MessagePayload;
-use presence::PresencePayload;
-use error::Error;
+use crate::message::MessagePayload;
+use crate::presence::PresencePayload;
+use crate::error::Error;
use jid::Jid;
-use ns;
+use crate::ns;
generate_attribute!(
/// The type of the error.
@@ -4,7 +4,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
-use message::MessagePayload;
+use crate::message::MessagePayload;
use jid::Jid;
generate_element!(
@@ -39,7 +39,7 @@ mod tests {
use super::*;
use try_from::TryFrom;
use minidom::Element;
- use error::Error;
+ use crate::error::Error;
use std::str::FromStr;
#[cfg(target_pointer_width = "32")]
@@ -4,7 +4,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
-use iq::{IqGetPayload, IqResultPayload};
+use crate::iq::{IqGetPayload, IqResultPayload};
generate_empty_element!(
/// Represents a query for the software version a remote entity is using.
@@ -41,7 +41,7 @@ mod tests {
use super::*;
use try_from::TryFrom;
use minidom::Element;
- use compare_elements::NamespaceAwareCompare;
+ use crate::compare_elements::NamespaceAwareCompare;
#[cfg(target_pointer_width = "32")]
#[test]