Detailed changes
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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")]
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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]
@@ -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;
@@ -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};
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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")]
@@ -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;
@@ -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;
@@ -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;
@@ -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")]
@@ -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;
@@ -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;
@@ -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]
@@ -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;
@@ -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;
@@ -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]
@@ -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]
@@ -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() {
@@ -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;
@@ -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]
@@ -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;
@@ -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;
@@ -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;
@@ -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.
@@ -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 {
$(
@@ -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;