Move Error, helpers and macros into a util module.

Emmanuel Gil Peyrot created

Change summary

src/attention.rs             |  2 
src/bind.rs                  |  2 
src/blocking.rs              |  2 
src/bookmarks.rs             |  2 
src/caps.rs                  |  2 
src/chatstates.rs            |  2 
src/component.rs             |  2 
src/data_forms.rs            |  2 
src/date.rs                  |  2 
src/delay.rs                 |  4 +-
src/disco.rs                 |  4 +-
src/ecaps2.rs                |  2 
src/eme.rs                   |  2 
src/forwarding.rs            |  2 
src/hashes.rs                |  4 +-
src/ibb.rs                   |  4 +-
src/ibr.rs                   |  4 +-
src/idle.rs                  |  2 
src/iq.rs                    |  4 +-
src/jingle.rs                |  2 
src/jingle_ft.rs             |  2 
src/jingle_ibb.rs            |  2 
src/jingle_message.rs        |  2 
src/jingle_s5b.rs            |  4 +-
src/lib.rs                   | 11 -----
src/mam.rs                   |  2 
src/media_element.rs         |  4 +-
src/message.rs               |  4 +-
src/message_correct.rs       |  2 
src/muc/muc.rs               |  4 +-
src/muc/user.rs              |  4 +-
src/nick.rs                  |  2 
src/ping.rs                  |  2 
src/presence.rs              |  4 +-
src/pubsub/event.rs          |  4 +-
src/pubsub/pubsub.rs         |  4 +-
src/roster.rs                |  4 +-
src/rsm.rs                   |  4 +-
src/sasl.rs                  |  4 +-
src/stanza_error.rs          |  2 
src/stanza_id.rs             |  2 
src/util/compare_elements.rs |  0 
src/util/error.rs            |  0 
src/util/helpers.rs          |  2 
src/util/macros.rs           | 76 +++++++++++++++++++-------------------
src/version.rs               |  2 
46 files changed, 98 insertions(+), 107 deletions(-)

Detailed changes

src/attention.rs 🔗

@@ -19,7 +19,7 @@ impl MessagePayload for Attention {}
 mod tests {
     use super::*;
     #[cfg(not(feature = "disable-validation"))]
-    use crate::error::Error;
+    use crate::util::error::Error;
     use minidom::Element;
     use try_from::TryFrom;
 

src/bind.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 crate::error::Error;
+use crate::util::error::Error;
 use crate::iq::{IqResultPayload, IqSetPayload};
 use crate::ns;
 use jid::Jid;

src/blocking.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 crate::error::Error;
+use crate::util::error::Error;
 use crate::iq::{IqGetPayload, IqResultPayload, IqSetPayload};
 use crate::ns;
 use jid::Jid;

src/bookmarks.rs 🔗

@@ -72,7 +72,7 @@ impl Storage {
 #[cfg(test)]
 mod tests {
     use super::*;
-    use crate::compare_elements::NamespaceAwareCompare;
+    use crate::util::compare_elements::NamespaceAwareCompare;
     use minidom::Element;
     use try_from::TryFrom;
 

src/caps.rs 🔗

@@ -6,7 +6,7 @@
 
 use crate::data_forms::DataForm;
 use crate::disco::{DiscoInfoQuery, DiscoInfoResult, Feature, Identity};
-use crate::error::Error;
+use crate::util::error::Error;
 use crate::hashes::{Algo, Hash};
 use crate::ns;
 use crate::presence::PresencePayload;

src/chatstates.rs 🔗

@@ -32,7 +32,7 @@ impl MessagePayload for ChatState {}
 #[cfg(test)]
 mod tests {
     use super::*;
-    use crate::error::Error;
+    use crate::util::error::Error;
     use crate::ns;
     use minidom::Element;
     use try_from::TryFrom;

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 crate::helpers::PlainText;
+use crate::util::helpers::PlainText;
 use digest::Digest;
 use sha1::Sha1;
 

src/data_forms.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 crate::error::Error;
+use crate::util::error::Error;
 use crate::media_element::MediaElement;
 use crate::ns;
 use minidom::Element;

src/date.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 crate::error::Error;
+use crate::util::error::Error;
 use chrono::{DateTime as ChronoDateTime, FixedOffset};
 use minidom::{ElementEmitter, IntoAttributeValue, IntoElements};
 use std::str::FromStr;

src/delay.rs 🔗

@@ -5,7 +5,7 @@
 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 use crate::date::DateTime;
-use crate::helpers::PlainText;
+use crate::util::helpers::PlainText;
 use crate::message::MessagePayload;
 use crate::presence::PresencePayload;
 use jid::Jid;
@@ -32,7 +32,7 @@ impl PresencePayload for Delay {}
 #[cfg(test)]
 mod tests {
     use super::*;
-    use crate::error::Error;
+    use crate::util::error::Error;
     use minidom::Element;
     use std::str::FromStr;
     use try_from::TryFrom;

src/disco.rs 🔗

@@ -5,7 +5,7 @@
 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 use crate::data_forms::{DataForm, DataFormType};
-use crate::error::Error;
+use crate::util::error::Error;
 use crate::iq::{IqGetPayload, IqResultPayload};
 use crate::ns;
 use jid::Jid;
@@ -236,7 +236,7 @@ impl IqResultPayload for DiscoItemsResult {}
 #[cfg(test)]
 mod tests {
     use super::*;
-    use crate::compare_elements::NamespaceAwareCompare;
+    use crate::util::compare_elements::NamespaceAwareCompare;
     use std::str::FromStr;
 
     #[cfg(target_pointer_width = "32")]

src/ecaps2.rs 🔗

@@ -156,7 +156,7 @@ pub fn query_ecaps2(hash: Hash) -> DiscoInfoQuery {
 #[cfg(test)]
 mod tests {
     use super::*;
-    use crate::error::Error;
+    use crate::util::error::Error;
     use minidom::Element;
     use try_from::TryFrom;
 

src/eme.rs 🔗

@@ -24,7 +24,7 @@ impl MessagePayload for ExplicitMessageEncryption {}
 #[cfg(test)]
 mod tests {
     use super::*;
-    use crate::error::Error;
+    use crate::util::error::Error;
     use minidom::Element;
     use try_from::TryFrom;
 

src/forwarding.rs 🔗

@@ -26,7 +26,7 @@ generate_element!(
 #[cfg(test)]
 mod tests {
     use super::*;
-    use crate::error::Error;
+    use crate::util::error::Error;
     use minidom::Element;
     use try_from::TryFrom;
 

src/hashes.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 crate::error::Error;
-use crate::helpers::Base64;
+use crate::util::error::Error;
+use crate::util::helpers::Base64;
 use base64;
 use minidom::IntoAttributeValue;
 use std::str::FromStr;

src/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 crate::helpers::Base64;
+use crate::util::helpers::Base64;
 use crate::iq::IqSetPayload;
 
 generate_id!(
@@ -72,7 +72,7 @@ impl IqSetPayload for Close {}
 #[cfg(test)]
 mod tests {
     use super::*;
-    use crate::error::Error;
+    use crate::util::error::Error;
     use minidom::Element;
     use std::error::Error as StdError;
     use try_from::TryFrom;

src/ibr.rs 🔗

@@ -5,7 +5,7 @@
 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 use crate::data_forms::DataForm;
-use crate::error::Error;
+use crate::util::error::Error;
 use crate::iq::{IqGetPayload, IqResultPayload, IqSetPayload};
 use crate::ns;
 use minidom::Element;
@@ -118,7 +118,7 @@ impl From<Query> for Element {
 #[cfg(test)]
 mod tests {
     use super::*;
-    use crate::compare_elements::NamespaceAwareCompare;
+    use crate::util::compare_elements::NamespaceAwareCompare;
 
     #[cfg(target_pointer_width = "32")]
     #[test]

src/idle.rs 🔗

@@ -21,7 +21,7 @@ impl PresencePayload for Idle {}
 #[cfg(test)]
 mod tests {
     use super::*;
-    use crate::error::Error;
+    use crate::util::error::Error;
     use minidom::Element;
     use std::error::Error as StdError;
     use std::str::FromStr;

src/iq.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 crate::error::Error;
+use crate::util::error::Error;
 use crate::ns;
 use crate::stanza_error::StanzaError;
 use jid::Jid;
@@ -218,7 +218,7 @@ impl From<Iq> for Element {
 #[cfg(test)]
 mod tests {
     use super::*;
-    use crate::compare_elements::NamespaceAwareCompare;
+    use crate::util::compare_elements::NamespaceAwareCompare;
     use crate::disco::DiscoInfoQuery;
     use crate::stanza_error::{DefinedCondition, ErrorType};
 

src/jingle.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 crate::error::Error;
+use crate::util::error::Error;
 use crate::iq::IqSetPayload;
 use crate::ns;
 use jid::Jid;

src/jingle_ft.rs 🔗

@@ -5,7 +5,7 @@
 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 use crate::date::DateTime;
-use crate::error::Error;
+use crate::util::error::Error;
 use crate::hashes::Hash;
 use crate::jingle::{ContentId, Creator};
 use crate::ns;

src/jingle_ibb.rs 🔗

@@ -24,7 +24,7 @@ attributes: [
 #[cfg(test)]
 mod tests {
     use super::*;
-    use crate::error::Error;
+    use crate::util::error::Error;
     use minidom::Element;
     use std::error::Error as StdError;
     use try_from::TryFrom;

src/jingle_message.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 crate::error::Error;
+use crate::util::error::Error;
 use crate::jingle::SessionId;
 use crate::ns;
 use minidom::Element;

src/jingle_s5b.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 crate::error::Error;
+use crate::util::error::Error;
 use crate::ns;
 use jid::Jid;
 use minidom::Element;
@@ -275,7 +275,7 @@ impl From<Transport> for Element {
 #[cfg(test)]
 mod tests {
     use super::*;
-    use crate::compare_elements::NamespaceAwareCompare;
+    use crate::util::compare_elements::NamespaceAwareCompare;
     use std::str::FromStr;
 
     #[cfg(target_pointer_width = "32")]

src/lib.rs 🔗

@@ -26,20 +26,11 @@
 
 pub use minidom::Element;
 
-/// Error type returned by every parser on failure.
-pub mod error;
 /// XML namespace definitions used through XMPP.
 pub mod ns;
 
-/// Various helpers.
-mod helpers;
-/// Helper macros to parse and serialise more easily.
 #[macro_use]
-mod macros;
-
-#[cfg(test)]
-/// Namespace-aware comparison for tests
-mod compare_elements;
+mod util;
 
 /// RFC 6120: Extensible Messaging and Presence Protocol (XMPP): Core
 pub mod bind;

src/mam.rs 🔗

@@ -5,7 +5,7 @@
 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 use crate::data_forms::DataForm;
-use crate::error::Error;
+use crate::util::error::Error;
 use crate::forwarding::Forwarded;
 use crate::iq::{IqGetPayload, IqResultPayload, IqSetPayload};
 use crate::message::MessagePayload;

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 crate::helpers::TrimmedPlainText;
+use crate::util::helpers::TrimmedPlainText;
 
 generate_element!(
     /// Represents an URI used in a media element.
@@ -46,7 +46,7 @@ generate_element!(
 mod tests {
     use super::*;
     use crate::data_forms::DataForm;
-    use crate::error::Error;
+    use crate::util::error::Error;
     use minidom::Element;
     use std::error::Error as StdError;
     use try_from::TryFrom;

src/message.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 crate::error::Error;
+use crate::util::error::Error;
 use crate::ns;
 use jid::Jid;
 use minidom::Element;
@@ -254,7 +254,7 @@ impl From<Message> for Element {
 #[cfg(test)]
 mod tests {
     use super::*;
-    use crate::compare_elements::NamespaceAwareCompare;
+    use crate::util::compare_elements::NamespaceAwareCompare;
     use std::str::FromStr;
 
     #[cfg(target_pointer_width = "32")]

src/message_correct.rs 🔗

@@ -21,7 +21,7 @@ impl MessagePayload for Replace {}
 #[cfg(test)]
 mod tests {
     use super::*;
-    use crate::error::Error;
+    use crate::util::error::Error;
     use minidom::Element;
     use try_from::TryFrom;
 

src/muc/muc.rs 🔗

@@ -102,8 +102,8 @@ impl Muc {
 #[cfg(test)]
 mod tests {
     use super::*;
-    use crate::compare_elements::NamespaceAwareCompare;
-    use crate::error::Error;
+    use crate::util::compare_elements::NamespaceAwareCompare;
+    use crate::util::error::Error;
     use minidom::Element;
     use std::str::FromStr;
     use try_from::TryFrom;

src/muc/user.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 crate::error::Error;
+use crate::util::error::Error;
 use crate::ns;
 use jid::Jid;
 use minidom::Element;
@@ -238,7 +238,7 @@ generate_element!(
 #[cfg(test)]
 mod tests {
     use super::*;
-    use crate::compare_elements::NamespaceAwareCompare;
+    use crate::util::compare_elements::NamespaceAwareCompare;
     use std::error::Error as StdError;
 
     #[test]

src/nick.rs 🔗

@@ -15,7 +15,7 @@ generate_elem_id!(
 mod tests {
     use super::*;
     #[cfg(not(feature = "disable-validation"))]
-    use crate::error::Error;
+    use crate::util::error::Error;
     use minidom::Element;
     use try_from::TryFrom;
 

src/ping.rs 🔗

@@ -21,7 +21,7 @@ impl IqGetPayload for Ping {}
 mod tests {
     use super::*;
     #[cfg(not(feature = "disable-validation"))]
-    use crate::error::Error;
+    use crate::util::error::Error;
     use minidom::Element;
     use try_from::TryFrom;
 

src/presence.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 crate::error::Error;
+use crate::util::error::Error;
 use crate::ns;
 use jid::Jid;
 use minidom::{Element, ElementEmitter, IntoAttributeValue, IntoElements};
@@ -354,7 +354,7 @@ impl From<Presence> for Element {
 #[cfg(test)]
 mod tests {
     use super::*;
-    use crate::compare_elements::NamespaceAwareCompare;
+    use crate::util::compare_elements::NamespaceAwareCompare;
 
     #[cfg(target_pointer_width = "32")]
     #[test]

src/pubsub/event.rs 🔗

@@ -6,7 +6,7 @@
 
 use crate::data_forms::DataForm;
 use crate::date::DateTime;
-use crate::error::Error;
+use crate::util::error::Error;
 use crate::ns;
 use crate::pubsub::{ItemId, NodeName, Subscription, SubscriptionId};
 use jid::Jid;
@@ -298,7 +298,7 @@ impl From<PubSubEvent> for Element {
 #[cfg(test)]
 mod tests {
     use super::*;
-    use crate::compare_elements::NamespaceAwareCompare;
+    use crate::util::compare_elements::NamespaceAwareCompare;
     use std::str::FromStr;
 
     #[test]

src/pubsub/pubsub.rs 🔗

@@ -5,7 +5,7 @@
 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 use crate::data_forms::DataForm;
-use crate::error::Error;
+use crate::util::error::Error;
 use crate::iq::{IqGetPayload, IqResultPayload, IqSetPayload};
 use crate::ns;
 use crate::pubsub::{ItemId, NodeName, Subscription, SubscriptionId};
@@ -540,7 +540,7 @@ impl From<PubSub> for Element {
 #[cfg(test)]
 mod tests {
     use super::*;
-    use crate::compare_elements::NamespaceAwareCompare;
+    use crate::util::compare_elements::NamespaceAwareCompare;
 
     #[test]
     fn create() {

src/roster.rs 🔗

@@ -92,8 +92,8 @@ impl IqResultPayload for Roster {}
 #[cfg(test)]
 mod tests {
     use super::*;
-    use crate::compare_elements::NamespaceAwareCompare;
-    use crate::error::Error;
+    use crate::util::compare_elements::NamespaceAwareCompare;
+    use crate::util::error::Error;
     use minidom::Element;
     use std::str::FromStr;
     use try_from::TryFrom;

src/rsm.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 crate::error::Error;
+use crate::util::error::Error;
 use crate::ns;
 use minidom::Element;
 use try_from::TryFrom;
@@ -180,7 +180,7 @@ impl From<SetResult> for Element {
 #[cfg(test)]
 mod tests {
     use super::*;
-    use crate::compare_elements::NamespaceAwareCompare;
+    use crate::util::compare_elements::NamespaceAwareCompare;
 
     #[cfg(target_pointer_width = "32")]
     #[test]

src/sasl.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 crate::error::Error;
-use crate::helpers::Base64;
+use crate::util::error::Error;
+use crate::util::helpers::Base64;
 use crate::ns;
 use minidom::Element;
 use std::collections::BTreeMap;

src/stanza_error.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 crate::error::Error;
+use crate::util::error::Error;
 use crate::message::MessagePayload;
 use crate::ns;
 use crate::presence::PresencePayload;

src/stanza_id.rs 🔗

@@ -37,7 +37,7 @@ impl MessagePayload for OriginId {}
 #[cfg(test)]
 mod tests {
     use super::*;
-    use crate::error::Error;
+    use crate::util::error::Error;
     use minidom::Element;
     use std::str::FromStr;
     use try_from::TryFrom;

src/helpers.rs → src/util/helpers.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 crate::error::Error;
+use crate::util::error::Error;
 use base64;
 
 /// Codec for plain text content.

src/macros.rs → src/util/macros.rs 🔗

@@ -25,7 +25,7 @@ macro_rules! get_attr {
         match $elem.attr($attr) {
             Some($value) => $func,
             None => {
-                return Err(crate::error::Error::ParseError(concat!(
+                return Err(crate::util::error::Error::ParseError(concat!(
                     "Required attribute '",
                     $attr,
                     "' missing."
@@ -58,11 +58,11 @@ macro_rules! generate_attribute {
             ),+
         }
         impl ::std::str::FromStr for $elem {
-            type Err = crate::error::Error;
-            fn from_str(s: &str) -> Result<$elem, crate::error::Error> {
+            type Err = crate::util::error::Error;
+            fn from_str(s: &str) -> Result<$elem, crate::util::error::Error> {
                 Ok(match s {
                     $($b => $elem::$a),+,
-                    _ => return Err(crate::error::Error::ParseError(concat!("Unknown value for '", $name, "' attribute."))),
+                    _ => return Err(crate::util::error::Error::ParseError(concat!("Unknown value for '", $name, "' attribute."))),
                 })
             }
         }
@@ -84,11 +84,11 @@ macro_rules! generate_attribute {
             ),+
         }
         impl ::std::str::FromStr for $elem {
-            type Err = crate::error::Error;
-            fn from_str(s: &str) -> Result<$elem, crate::error::Error> {
+            type Err = crate::util::error::Error;
+            fn from_str(s: &str) -> Result<$elem, crate::util::error::Error> {
                 Ok(match s {
                     $($b => $elem::$a),+,
-                    _ => return Err(crate::error::Error::ParseError(concat!("Unknown value for '", $name, "' attribute."))),
+                    _ => return Err(crate::util::error::Error::ParseError(concat!("Unknown value for '", $name, "' attribute."))),
                 })
             }
         }
@@ -117,11 +117,11 @@ macro_rules! generate_attribute {
             None,
         }
         impl ::std::str::FromStr for $elem {
-            type Err = crate::error::Error;
-            fn from_str(s: &str) -> Result<Self, crate::error::Error> {
+            type Err = crate::util::error::Error;
+            fn from_str(s: &str) -> Result<Self, crate::util::error::Error> {
                 Ok(match s {
                     $value => $elem::$symbol,
-                    _ => return Err(crate::error::Error::ParseError(concat!("Unknown value for '", $name, "' attribute."))),
+                    _ => return Err(crate::util::error::Error::ParseError(concat!("Unknown value for '", $name, "' attribute."))),
                 })
             }
         }
@@ -149,12 +149,12 @@ macro_rules! generate_attribute {
             False,
         }
         impl ::std::str::FromStr for $elem {
-            type Err = crate::error::Error;
-            fn from_str(s: &str) -> Result<Self, crate::error::Error> {
+            type Err = crate::util::error::Error;
+            fn from_str(s: &str) -> Result<Self, crate::util::error::Error> {
                 Ok(match s {
                     "true" | "1" => $elem::True,
                     "false" | "0" => $elem::False,
-                    _ => return Err(crate::error::Error::ParseError(concat!("Unknown value for '", $name, "' attribute."))),
+                    _ => return Err(crate::util::error::Error::ParseError(concat!("Unknown value for '", $name, "' attribute."))),
                 })
             }
         }
@@ -188,14 +188,14 @@ macro_rules! generate_element_enum {
             ),+
         }
         impl ::try_from::TryFrom<::minidom::Element> for $elem {
-            type Err = crate::error::Error;
-            fn try_from(elem: ::minidom::Element) -> Result<$elem, crate::error::Error> {
+            type Err = crate::util::error::Error;
+            fn try_from(elem: ::minidom::Element) -> Result<$elem, crate::util::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(crate::error::Error::ParseError(concat!("This is not a ", $name, " element."))),
+                    _ => return Err(crate::util::error::Error::ParseError(concat!("This is not a ", $name, " element."))),
                 })
             }
         }
@@ -227,14 +227,14 @@ macro_rules! generate_attribute_enum {
             ),+
         }
         impl ::try_from::TryFrom<::minidom::Element> for $elem {
-            type Err = crate::error::Error;
-            fn try_from(elem: ::minidom::Element) -> Result<$elem, crate::error::Error> {
+            type Err = crate::util::error::Error;
+            fn try_from(elem: ::minidom::Element) -> Result<$elem, crate::util::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(crate::error::Error::ParseError(concat!("Invalid ", $name, " ", $attr, " value."))),
+                    _ => return Err(crate::util::error::Error::ParseError(concat!("Invalid ", $name, " ", $attr, " value."))),
                 })
             }
         }
@@ -257,7 +257,7 @@ macro_rules! check_self {
     };
     ($elem:ident, $name:tt, $ns:ident, $pretty_name:tt) => {
         if !$elem.is($name, crate::ns::$ns) {
-            return Err(crate::error::Error::ParseError(concat!(
+            return Err(crate::util::error::Error::ParseError(concat!(
                 "This is not a ",
                 $pretty_name,
                 " element."
@@ -269,7 +269,7 @@ macro_rules! check_self {
 macro_rules! check_ns_only {
     ($elem:ident, $name:tt, $ns:ident) => {
         if !$elem.has_ns(crate::ns::$ns) {
-            return Err(crate::error::Error::ParseError(concat!(
+            return Err(crate::util::error::Error::ParseError(concat!(
                 "This is not a ",
                 $name,
                 " element."
@@ -282,7 +282,7 @@ macro_rules! check_no_children {
     ($elem:ident, $name:tt) => {
         #[cfg(not(feature = "disable-validation"))]
         for _ in $elem.children() {
-            return Err(crate::error::Error::ParseError(concat!(
+            return Err(crate::util::error::Error::ParseError(concat!(
                 "Unknown child in ",
                 $name,
                 " element."
@@ -295,7 +295,7 @@ macro_rules! check_no_attributes {
     ($elem:ident, $name:tt) => {
         #[cfg(not(feature = "disable-validation"))]
         for _ in $elem.attrs() {
-            return Err(crate::error::Error::ParseError(concat!(
+            return Err(crate::util::error::Error::ParseError(concat!(
                 "Unknown attribute in ",
                 $name,
                 " element."
@@ -313,7 +313,7 @@ macro_rules! check_no_unknown_attributes {
                     continue;
                 }
             )*
-            return Err(crate::error::Error::ParseError(concat!("Unknown attribute in ", $name, " element.")));
+            return Err(crate::util::error::Error::ParseError(concat!("Unknown attribute in ", $name, " element.")));
         }
     );
 }
@@ -325,9 +325,9 @@ macro_rules! generate_empty_element {
         pub struct $elem;
 
         impl ::try_from::TryFrom<::minidom::Element> for $elem {
-            type Err = crate::error::Error;
+            type Err = crate::util::error::Error;
 
-            fn try_from(elem: ::minidom::Element) -> Result<$elem, crate::error::Error> {
+            fn try_from(elem: ::minidom::Element) -> Result<$elem, crate::util::error::Error> {
                 check_self!(elem, $name, $ns);
                 check_no_children!(elem, $name);
                 check_no_attributes!(elem, $name);
@@ -351,8 +351,8 @@ macro_rules! generate_id {
         #[derive(Debug, Clone, PartialEq, Eq, Hash)]
         pub struct $elem(pub String);
         impl ::std::str::FromStr for $elem {
-            type Err = crate::error::Error;
-            fn from_str(s: &str) -> Result<$elem, crate::error::Error> {
+            type Err = crate::util::error::Error;
+            fn from_str(s: &str) -> Result<$elem, crate::util::error::Error> {
                 // TODO: add a way to parse that differently when needed.
                 Ok($elem(String::from(s)))
             }
@@ -371,15 +371,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 = crate::error::Error;
-            fn from_str(s: &str) -> Result<$elem, crate::error::Error> {
+            type Err = crate::util::error::Error;
+            fn from_str(s: &str) -> Result<$elem, crate::util::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 = crate::error::Error;
-            fn try_from(elem: ::minidom::Element) -> Result<$elem, crate::error::Error> {
+            type Err = crate::util::error::Error;
+            fn try_from(elem: ::minidom::Element) -> Result<$elem, crate::util::error::Error> {
                 check_self!(elem, $name, $ns);
                 check_no_children!(elem, $name);
                 check_no_attributes!(elem, $name);
@@ -440,7 +440,7 @@ macro_rules! do_parse_elem {
     };
     ($temp:ident: Option = $constructor:ident => $elem:ident, $name:tt, $parent_name:tt) => {
         if $temp.is_some() {
-            return Err(crate::error::Error::ParseError(concat!(
+            return Err(crate::util::error::Error::ParseError(concat!(
                 "Element ",
                 $parent_name,
                 " must not have more than one ",
@@ -452,7 +452,7 @@ macro_rules! do_parse_elem {
     };
     ($temp:ident: Required = $constructor:ident => $elem:ident, $name:tt, $parent_name:tt) => {
         if $temp.is_some() {
-            return Err(crate::error::Error::ParseError(concat!(
+            return Err(crate::util::error::Error::ParseError(concat!(
                 "Element ",
                 $parent_name,
                 " must not have more than one ",
@@ -472,7 +472,7 @@ macro_rules! finish_parse_elem {
         $temp
     };
     ($temp:ident: Required = $name:tt, $parent_name:tt) => {
-        $temp.ok_or(crate::error::Error::ParseError(concat!(
+        $temp.ok_or(crate::util::error::Error::ParseError(concat!(
             "Missing child ",
             $name,
             " in ",
@@ -540,9 +540,9 @@ macro_rules! generate_element {
         }
 
         impl ::try_from::TryFrom<::minidom::Element> for $elem {
-            type Err = crate::error::Error;
+            type Err = crate::util::error::Error;
 
-            fn try_from(elem: ::minidom::Element) -> Result<$elem, crate::error::Error> {
+            fn try_from(elem: ::minidom::Element) -> Result<$elem, crate::util::error::Error> {
                 check_self!(elem, $name, $ns);
                 check_no_unknown_attributes!(elem, $name, [$($attr_name),*]);
                 $(
@@ -555,7 +555,7 @@ macro_rules! generate_element {
                         continue;
                     }
                     )*
-                    return Err(crate::error::Error::ParseError(concat!("Unknown child in ", $name, " element.")));
+                    return Err(crate::util::error::Error::ParseError(concat!("Unknown child in ", $name, " element.")));
                 }
                 Ok($elem {
                     $(

src/version.rs 🔗

@@ -41,7 +41,7 @@ impl IqResultPayload for VersionResult {}
 #[cfg(test)]
 mod tests {
     use super::*;
-    use crate::compare_elements::NamespaceAwareCompare;
+    use crate::util::compare_elements::NamespaceAwareCompare;
     use minidom::Element;
     use try_from::TryFrom;