From 6b2dd8fe5e27a168b96e89432a5c1eb7fc2f90c2 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Tue, 18 Dec 2018 15:27:30 +0100 Subject: [PATCH] Run `cargo fix --edition` to move to Edition 2018. --- 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(-) diff --git a/Cargo.toml b/Cargo.toml index a438baec..8fd7253b 100644 --- a/Cargo.toml +++ b/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" diff --git a/src/attention.rs b/src/attention.rs index 4bfffd7e..e71b2644 100644 --- a/src/attention.rs +++ b/src/attention.rs @@ -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() { diff --git a/src/bind.rs b/src/bind.rs index b6ec55d4..81187ae3 100644 --- a/src/bind.rs +++ b/src/bind.rs @@ -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. diff --git a/src/blocking.rs b/src/blocking.rs index cd3f8fd8..fd89c484 100644 --- a/src/blocking.rs +++ b/src/blocking.rs @@ -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 diff --git a/src/bookmarks.rs b/src/bookmarks.rs index 7f68930d..8f88845f 100644 --- a/src/bookmarks.rs +++ b/src/bookmarks.rs @@ -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] diff --git a/src/caps.rs b/src/caps.rs index 22ac1930..ce44e54c 100644 --- a/src/caps.rs +++ b/src/caps.rs @@ -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")] diff --git a/src/chatstates.rs b/src/chatstates.rs index 477bdded..2d4d3830 100644 --- a/src/chatstates.rs +++ b/src/chatstates.rs @@ -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() { diff --git a/src/component.rs b/src/component.rs index 0c9319cd..1fbb7ff3 100644 --- a/src/component.rs +++ b/src/component.rs @@ -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; diff --git a/src/data_forms.rs b/src/data_forms.rs index edf2608c..622820d3 100644 --- a/src/data_forms.rs +++ b/src/data_forms.rs @@ -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. diff --git a/src/date.rs b/src/date.rs index 5f2038de..34bef242 100644 --- a/src/date.rs +++ b/src/date.rs @@ -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 diff --git a/src/delay.rs b/src/delay.rs index 46fec0fb..e67b2906 100644 --- a/src/delay.rs +++ b/src/delay.rs @@ -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")] diff --git a/src/disco.rs b/src/disco.rs index e76b21f2..7c765fb1 100644 --- a/src/disco.rs +++ b/src/disco.rs @@ -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 `` 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")] diff --git a/src/ecaps2.rs b/src/ecaps2.rs index ea5e03df..ecadc153 100644 --- a/src/ecaps2.rs +++ b/src/ecaps2.rs @@ -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] diff --git a/src/eme.rs b/src/eme.rs index 417bbe52..5c13f510 100644 --- a/src/eme.rs +++ b/src/eme.rs @@ -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 `` 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] diff --git a/src/forwarding.rs b/src/forwarding.rs index 11efb610..9f725132 100644 --- a/src/forwarding.rs +++ b/src/forwarding.rs @@ -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] diff --git a/src/hashes.rs b/src/hashes.rs index 5fbf5b90..93a17291 100644 --- a/src/hashes.rs +++ b/src/hashes.rs @@ -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. diff --git a/src/helpers.rs b/src/helpers.rs index 4db2d2c1..9d4f3ecb 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -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; diff --git a/src/ibb.rs b/src/ibb.rs index 87b335ec..19af5881 100644 --- a/src/ibb.rs +++ b/src/ibb.rs @@ -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")] diff --git a/src/ibr.rs b/src/ibr.rs index 4d76a9d8..4afe719e 100644 --- a/src/ibr.rs +++ b/src/ibr.rs @@ -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 for Element { #[cfg(test)] mod tests { use super::*; - use compare_elements::NamespaceAwareCompare; + use crate::compare_elements::NamespaceAwareCompare; #[cfg(target_pointer_width = "32")] #[test] diff --git a/src/idle.rs b/src/idle.rs index 45352a22..53ededda 100644 --- a/src/idle.rs +++ b/src/idle.rs @@ -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; diff --git a/src/iq.rs b/src/iq.rs index ff1e7b1f..1657fcb6 100644 --- a/src/iq.rs +++ b/src/iq.rs @@ -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 ``. pub trait IqGetPayload: TryFrom + Into {} @@ -222,9 +222,9 @@ impl From 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] diff --git a/src/jingle.rs b/src/jingle.rs index 7e4ea82b..720eae86 100644 --- a/src/jingle.rs +++ b/src/jingle.rs @@ -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. diff --git a/src/jingle_ft.rs b/src/jingle_ft.rs index 604e6ee5..15bb4f32 100644 --- a/src/jingle_ft.rs +++ b/src/jingle_ft.rs @@ -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")] diff --git a/src/jingle_ibb.rs b/src/jingle_ibb.rs index e02a4347..129f7ad4 100644 --- a/src/jingle_ibb.rs +++ b/src/jingle_ibb.rs @@ -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")] diff --git a/src/jingle_message.rs b/src/jingle_message.rs index 1bef3269..2f90d2a5 100644 --- a/src/jingle_message.rs +++ b/src/jingle_message.rs @@ -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. diff --git a/src/jingle_s5b.rs b/src/jingle_s5b.rs index 904a4d77..4d660d28 100644 --- a/src/jingle_s5b.rs +++ b/src/jingle_s5b.rs @@ -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 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] diff --git a/src/macros.rs b/src/macros.rs index 3deade1d..da96b67a 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -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 { + type Err = crate::error::Error; + fn from_str(s: &str) -> Result { 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) )* diff --git a/src/mam.rs b/src/mam.rs index 819bc462..ec88ead6 100644 --- a/src/mam.rs +++ b/src/mam.rs @@ -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. diff --git a/src/media_element.rs b/src/media_element.rs index dc0c2af7..2bc512d8 100644 --- a/src/media_element.rs +++ b/src/media_element.rs @@ -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")] diff --git a/src/message.rs b/src/message.rs index 9c392b79..caae40ab 100644 --- a/src/message.rs +++ b/src/message.rs @@ -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 ``. pub trait MessagePayload: TryFrom + Into {} @@ -232,7 +232,7 @@ impl From 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] diff --git a/src/message_correct.rs b/src/message_correct.rs index 06b433f9..24b56919 100644 --- a/src/message_correct.rs +++ b/src/message_correct.rs @@ -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] diff --git a/src/muc/muc.rs b/src/muc/muc.rs index 5e5d65e8..a49c1bb8 100644 --- a/src/muc/muc.rs +++ b/src/muc/muc.rs @@ -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() { diff --git a/src/muc/user.rs b/src/muc/user.rs index bf0fb308..7d114abd 100644 --- a/src/muc/user.rs +++ b/src/muc/user.rs @@ -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() { diff --git a/src/nick.rs b/src/nick.rs index 7a366657..360348bd 100644 --- a/src/nick.rs +++ b/src/nick.rs @@ -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] diff --git a/src/ping.rs b/src/ping.rs index 557f535a..ddb636d3 100644 --- a/src/ping.rs +++ b/src/ping.rs @@ -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() { diff --git a/src/presence.rs b/src/presence.rs index 2cb115f5..aece0cff 100644 --- a/src/presence.rs +++ b/src/presence.rs @@ -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 ``. pub trait PresencePayload: TryFrom + Into {} @@ -331,7 +331,7 @@ impl From for Element { #[cfg(test)] mod tests { use super::*; - use compare_elements::NamespaceAwareCompare; + use crate::compare_elements::NamespaceAwareCompare; #[cfg(target_pointer_width = "32")] #[test] diff --git a/src/pubsub/event.rs b/src/pubsub/event.rs index 61b4396e..c1ccace3 100644 --- a/src/pubsub/event.rs +++ b/src/pubsub/event.rs @@ -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 for Element { mod tests { use super::*; use std::str::FromStr; - use compare_elements::NamespaceAwareCompare; + use crate::compare_elements::NamespaceAwareCompare; #[test] fn missing_items() { diff --git a/src/pubsub/pubsub.rs b/src/pubsub/pubsub.rs index 52f51007..cf3d9803 100644 --- a/src/pubsub/pubsub.rs +++ b/src/pubsub/pubsub.rs @@ -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 for Element { #[cfg(test)] mod tests { use super::*; - use compare_elements::NamespaceAwareCompare; + use crate::compare_elements::NamespaceAwareCompare; #[test] fn create() { diff --git a/src/receipts.rs b/src/receipts.rs index 49759c77..61877f57 100644 --- a/src/receipts.rs +++ b/src/receipts.rs @@ -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] diff --git a/src/roster.rs b/src/roster.rs index c1f8641e..86d02309 100644 --- a/src/roster.rs +++ b/src/roster.rs @@ -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] diff --git a/src/rsm.rs b/src/rsm.rs index fb321fa5..6bb02ba7 100644 --- a/src/rsm.rs +++ b/src/rsm.rs @@ -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 for Element { #[cfg(test)] mod tests { use super::*; - use compare_elements::NamespaceAwareCompare; + use crate::compare_elements::NamespaceAwareCompare; #[cfg(target_pointer_width = "32")] #[test] diff --git a/src/sasl.rs b/src/sasl.rs index 1ec44af0..30fa653a 100644 --- a/src/sasl.rs +++ b/src/sasl.rs @@ -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. diff --git a/src/sm.rs b/src/sm.rs index 404b54eb..b0d08d3e 100644 --- a/src/sm.rs +++ b/src/sm.rs @@ -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. diff --git a/src/stanza_error.rs b/src/stanza_error.rs index 750823d3..ec31ecb1 100644 --- a/src/stanza_error.rs +++ b/src/stanza_error.rs @@ -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. diff --git a/src/stanza_id.rs b/src/stanza_id.rs index e45b528c..87595d43 100644 --- a/src/stanza_id.rs +++ b/src/stanza_id.rs @@ -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")] diff --git a/src/version.rs b/src/version.rs index cbd95839..4e969f4a 100644 --- a/src/version.rs +++ b/src/version.rs @@ -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]