macros: Remove use requirement on minidom::Element.

This commit is contained in:
Emmanuel Gil Peyrot 2018-05-14 16:17:21 +02:00
commit 6f497027f5
20 changed files with 55 additions and 65 deletions

View file

@ -4,8 +4,6 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this // 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/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
use minidom::Element;
use error::Error; use error::Error;
use ns; use ns;
@ -16,6 +14,7 @@ generate_empty_element!(Attention, "attention", ns::ATTENTION);
mod tests { mod tests {
use super::*; use super::*;
use try_from::TryFrom; use try_from::TryFrom;
use minidom::Element;
#[test] #[test]
fn test_simple() { fn test_simple() {

View file

@ -6,8 +6,6 @@
#![deny(missing_docs)] #![deny(missing_docs)]
use minidom::Element;
use error::Error; use error::Error;
use ns; use ns;
@ -37,6 +35,7 @@ generate_element_enum!(
mod tests { mod tests {
use super::*; use super::*;
use try_from::TryFrom; use try_from::TryFrom;
use minidom::Element;
#[test] #[test]
fn test_simple() { fn test_simple() {

View file

@ -4,7 +4,6 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this // 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/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
use minidom::Element;
use error::Error; use error::Error;
use helpers::PlainText; use helpers::PlainText;
use ns; use ns;
@ -37,6 +36,7 @@ impl Handshake {
mod tests { mod tests {
use super::*; use super::*;
use try_from::TryFrom; use try_from::TryFrom;
use minidom::Element;
#[test] #[test]
fn test_simple() { fn test_simple() {

View file

@ -4,7 +4,6 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this // 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/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
use minidom::Element;
use date::DateTime; use date::DateTime;
use error::Error; use error::Error;
@ -25,6 +24,7 @@ generate_element_with_text!(Delay, "delay", ns::DELAY,
mod tests { mod tests {
use super::*; use super::*;
use try_from::TryFrom; use try_from::TryFrom;
use minidom::Element;
use std::str::FromStr; use std::str::FromStr;
#[test] #[test]

View file

@ -4,8 +4,6 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this // 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/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
use minidom::Element;
use error::Error; use error::Error;
use ns; use ns;
@ -25,6 +23,7 @@ ExplicitMessageEncryption, "encryption", ns::EME, [
mod tests { mod tests {
use super::*; use super::*;
use try_from::TryFrom; use try_from::TryFrom;
use minidom::Element;
#[test] #[test]
fn test_simple() { fn test_simple() {

View file

@ -6,7 +6,7 @@
use std::str::FromStr; use std::str::FromStr;
use minidom::{Element, IntoAttributeValue}; use minidom::IntoAttributeValue;
use error::Error; use error::Error;
@ -93,6 +93,7 @@ impl Hash {
mod tests { mod tests {
use super::*; use super::*;
use try_from::TryFrom; use try_from::TryFrom;
use minidom::Element;
#[test] #[test]
fn test_simple() { fn test_simple() {

View file

@ -4,8 +4,6 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this // 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/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
use minidom::Element;
use error::Error; use error::Error;
use ns; use ns;
@ -38,6 +36,7 @@ generate_element_with_only_attributes!(Close, "close", ns::IBB, [
mod tests { mod tests {
use super::*; use super::*;
use try_from::TryFrom; use try_from::TryFrom;
use minidom::Element;
use std::error::Error as StdError; use std::error::Error as StdError;
#[test] #[test]

View file

@ -4,7 +4,6 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this // 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/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
use minidom::Element;
use date::DateTime; use date::DateTime;
use error::Error; use error::Error;
@ -19,6 +18,7 @@ generate_element_with_only_attributes!(Idle, "idle", ns::IDLE, [
mod tests { mod tests {
use super::*; use super::*;
use try_from::TryFrom; use try_from::TryFrom;
use minidom::Element;
use std::str::FromStr; use std::str::FromStr;
use std::error::Error as StdError; use std::error::Error as StdError;

View file

@ -4,8 +4,6 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this // 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/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
use minidom::Element;
use error::Error; use error::Error;
use ns; use ns;
@ -24,6 +22,7 @@ generate_element_with_only_attributes!(Transport, "transport", ns::JINGLE_IBB, [
mod tests { mod tests {
use super::*; use super::*;
use try_from::TryFrom; use try_from::TryFrom;
use minidom::Element;
use std::error::Error as StdError; use std::error::Error as StdError;
#[test] #[test]

View file

@ -116,9 +116,9 @@ macro_rules! generate_element_enum {
$enum $enum
),+ ),+
} }
impl ::try_from::TryFrom<Element> for $elem { impl ::try_from::TryFrom<::minidom::Element> for $elem {
type Err = Error; type Err = Error;
fn try_from(elem: Element) -> Result<$elem, Error> { fn try_from(elem: ::minidom::Element) -> Result<$elem, Error> {
check_ns_only!(elem, $name, $ns); check_ns_only!(elem, $name, $ns);
check_no_children!(elem, $name); check_no_children!(elem, $name);
check_no_attributes!(elem, $name); check_no_attributes!(elem, $name);
@ -128,9 +128,9 @@ macro_rules! generate_element_enum {
}) })
} }
} }
impl From<$elem> for Element { impl From<$elem> for ::minidom::Element {
fn from(elem: $elem) -> Element { fn from(elem: $elem) -> ::minidom::Element {
Element::builder(match elem { ::minidom::Element::builder(match elem {
$($elem::$enum => $enum_name,)+ $($elem::$enum => $enum_name,)+
}).ns($ns) }).ns($ns)
.build() .build()
@ -152,9 +152,9 @@ macro_rules! generate_attribute_enum {
$enum $enum
),+ ),+
} }
impl ::try_from::TryFrom<Element> for $elem { impl ::try_from::TryFrom<::minidom::Element> for $elem {
type Err = Error; type Err = Error;
fn try_from(elem: Element) -> Result<$elem, Error> { fn try_from(elem: ::minidom::Element) -> Result<$elem, Error> {
check_ns_only!(elem, $name, $ns); check_ns_only!(elem, $name, $ns);
check_no_children!(elem, $name); check_no_children!(elem, $name);
check_no_unknown_attributes!(elem, $name, [$attr]); check_no_unknown_attributes!(elem, $name, [$attr]);
@ -164,9 +164,9 @@ macro_rules! generate_attribute_enum {
}) })
} }
} }
impl From<$elem> for Element { impl From<$elem> for ::minidom::Element {
fn from(elem: $elem) -> Element { fn from(elem: $elem) -> ::minidom::Element {
Element::builder($name) ::minidom::Element::builder($name)
.ns($ns) .ns($ns)
.attr($attr, match elem { .attr($attr, match elem {
$($elem::$enum => $enum_name,)+ $($elem::$enum => $enum_name,)+
@ -231,10 +231,10 @@ macro_rules! generate_empty_element {
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct $elem; pub struct $elem;
impl ::try_from::TryFrom<Element> for $elem { impl ::try_from::TryFrom<::minidom::Element> for $elem {
type Err = Error; type Err = Error;
fn try_from(elem: Element) -> Result<$elem, Error> { fn try_from(elem: ::minidom::Element) -> Result<$elem, Error> {
check_self!(elem, $name, $ns); check_self!(elem, $name, $ns);
check_no_children!(elem, $name); check_no_children!(elem, $name);
check_no_attributes!(elem, $name); check_no_attributes!(elem, $name);
@ -242,9 +242,9 @@ macro_rules! generate_empty_element {
} }
} }
impl From<$elem> for Element { impl From<$elem> for ::minidom::Element {
fn from(_: $elem) -> Element { fn from(_: $elem) -> ::minidom::Element {
Element::builder($name) ::minidom::Element::builder($name)
.ns($ns) .ns($ns)
.build() .build()
} }
@ -266,10 +266,10 @@ macro_rules! generate_element_with_only_attributes {
)* )*
} }
impl ::try_from::TryFrom<Element> for $elem { impl ::try_from::TryFrom<::minidom::Element> for $elem {
type Err = Error; type Err = Error;
fn try_from(elem: Element) -> Result<$elem, Error> { fn try_from(elem: ::minidom::Element) -> Result<$elem, Error> {
check_self!(elem, $name, $ns); check_self!(elem, $name, $ns);
check_no_children!(elem, $name); check_no_children!(elem, $name);
check_no_unknown_attributes!(elem, $name, [$($attr_name),*]); check_no_unknown_attributes!(elem, $name, [$($attr_name),*]);
@ -281,9 +281,9 @@ macro_rules! generate_element_with_only_attributes {
} }
} }
impl From<$elem> for Element { impl From<$elem> for ::minidom::Element {
fn from(elem: $elem) -> Element { fn from(elem: $elem) -> ::minidom::Element {
Element::builder($name) ::minidom::Element::builder($name)
.ns($ns) .ns($ns)
$( $(
.attr($attr_name, elem.$attr) .attr($attr_name, elem.$attr)
@ -324,9 +324,9 @@ macro_rules! generate_elem_id {
Ok($elem(String::from(s))) Ok($elem(String::from(s)))
} }
} }
impl ::try_from::TryFrom<Element> for $elem { impl ::try_from::TryFrom<::minidom::Element> for $elem {
type Err = Error; type Err = Error;
fn try_from(elem: Element) -> Result<$elem, Error> { fn try_from(elem: ::minidom::Element) -> Result<$elem, Error> {
check_self!(elem, $name, $ns); check_self!(elem, $name, $ns);
check_no_children!(elem, $name); check_no_children!(elem, $name);
check_no_attributes!(elem, $name); check_no_attributes!(elem, $name);
@ -334,9 +334,9 @@ macro_rules! generate_elem_id {
Ok($elem(elem.text())) Ok($elem(elem.text()))
} }
} }
impl From<$elem> for Element { impl From<$elem> for ::minidom::Element {
fn from(elem: $elem) -> Element { fn from(elem: $elem) -> ::minidom::Element {
Element::builder($name) ::minidom::Element::builder($name)
.ns($ns) .ns($ns)
.append(elem.0) .append(elem.0)
.build() .build()
@ -360,10 +360,10 @@ macro_rules! generate_element_with_text {
pub $text_ident: $text_type, pub $text_ident: $text_type,
} }
impl ::try_from::TryFrom<Element> for $elem { impl ::try_from::TryFrom<::minidom::Element> for $elem {
type Err = Error; type Err = Error;
fn try_from(elem: Element) -> Result<$elem, Error> { fn try_from(elem: ::minidom::Element) -> Result<$elem, Error> {
check_self!(elem, $name, $ns); check_self!(elem, $name, $ns);
check_no_children!(elem, $name); check_no_children!(elem, $name);
check_no_unknown_attributes!(elem, $name, [$($attr_name),*]); check_no_unknown_attributes!(elem, $name, [$($attr_name),*]);
@ -376,9 +376,9 @@ macro_rules! generate_element_with_text {
} }
} }
impl From<$elem> for Element { impl From<$elem> for ::minidom::Element {
fn from(elem: $elem) -> Element { fn from(elem: $elem) -> ::minidom::Element {
Element::builder($name) ::minidom::Element::builder($name)
.ns($ns) .ns($ns)
$( $(
.attr($attr_name, elem.$attr) .attr($attr_name, elem.$attr)
@ -405,10 +405,10 @@ macro_rules! generate_element_with_children {
)* )*
} }
impl ::try_from::TryFrom<Element> for $elem { impl ::try_from::TryFrom<::minidom::Element> for $elem {
type Err = Error; type Err = Error;
fn try_from(elem: Element) -> Result<$elem, Error> { fn try_from(elem: ::minidom::Element) -> Result<$elem, Error> {
check_self!(elem, $name, $ns); check_self!(elem, $name, $ns);
check_no_unknown_attributes!(elem, $name, [$($attr_name),*]); check_no_unknown_attributes!(elem, $name, [$($attr_name),*]);
let mut parsed_children = vec!(); let mut parsed_children = vec!();
@ -433,9 +433,9 @@ macro_rules! generate_element_with_children {
} }
} }
impl From<$elem> for Element { impl From<$elem> for ::minidom::Element {
fn from(elem: $elem) -> Element { fn from(elem: $elem) -> ::minidom::Element {
Element::builder($name) ::minidom::Element::builder($name)
.ns($ns) .ns($ns)
$( $(
.attr($attr_name, elem.$attr) .attr($attr_name, elem.$attr)

View file

@ -4,8 +4,6 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this // 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/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
use minidom::Element;
use error::Error; use error::Error;
use ns; use ns;
@ -32,6 +30,7 @@ generate_element_with_children!(MediaElement, "media", ns::MEDIA_ELEMENT,
mod tests { mod tests {
use super::*; use super::*;
use try_from::TryFrom; use try_from::TryFrom;
use minidom::Element;
use data_forms::DataForm; use data_forms::DataForm;
use std::error::Error as StdError; use std::error::Error as StdError;

View file

@ -4,8 +4,6 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this // 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/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
use minidom::Element;
use error::Error; use error::Error;
use ns; use ns;
@ -18,6 +16,7 @@ generate_element_with_only_attributes!(Replace, "replace", ns::MESSAGE_CORRECT,
mod tests { mod tests {
use super::*; use super::*;
use try_from::TryFrom; use try_from::TryFrom;
use minidom::Element;
#[test] #[test]
fn test_simple() { fn test_simple() {

View file

@ -6,8 +6,6 @@
#![deny(missing_docs)] #![deny(missing_docs)]
use minidom::Element;
use error::Error; use error::Error;
use ns; use ns;
@ -273,6 +271,7 @@ generate_element_enum!(
mod tests { mod tests {
use super::*; use super::*;
use try_from::TryFrom; use try_from::TryFrom;
use minidom::Element;
#[test] #[test]
fn test_simple() { fn test_simple() {

View file

@ -5,8 +5,6 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this // 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/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
use minidom::Element;
use error::Error; use error::Error;
use ns; use ns;
@ -17,6 +15,7 @@ generate_empty_element!(Ping, "ping", ns::PING);
mod tests { mod tests {
use super::*; use super::*;
use try_from::TryFrom; use try_from::TryFrom;
use minidom::Element;
#[test] #[test]
fn test_simple() { fn test_simple() {

View file

@ -4,8 +4,6 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this // 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/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
use minidom::Element;
use error::Error; use error::Error;
use ns; use ns;
@ -20,6 +18,7 @@ generate_element_with_only_attributes!(Received, "received", ns::RECEIPTS, [
mod tests { mod tests {
use super::*; use super::*;
use try_from::TryFrom; use try_from::TryFrom;
use minidom::Element;
#[test] #[test]
fn test_simple() { fn test_simple() {

View file

@ -4,7 +4,6 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this // 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/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
use minidom::Element;
use jid::Jid; use jid::Jid;
use error::Error; use error::Error;
@ -62,6 +61,7 @@ generate_element_with_children!(
mod tests { mod tests {
use super::*; use super::*;
use try_from::TryFrom; use try_from::TryFrom;
use minidom::Element;
use std::str::FromStr; use std::str::FromStr;
use compare_elements::NamespaceAwareCompare; use compare_elements::NamespaceAwareCompare;

View file

@ -4,8 +4,6 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this // 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/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
use minidom::Element;
use error::Error; use error::Error;
use ns; use ns;
@ -40,6 +38,7 @@ generate_element_with_text!(Success, "success", ns::SASL,
mod tests { mod tests {
use super::*; use super::*;
use try_from::TryFrom; use try_from::TryFrom;
use minidom::Element;
#[test] #[test]
fn test_simple() { fn test_simple() {

View file

@ -4,7 +4,6 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this // 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/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
use minidom::Element;
use jid::Jid; use jid::Jid;
use error::Error; use error::Error;
@ -24,6 +23,7 @@ generate_element_with_only_attributes!(OriginId, "origin-id", ns::SID, [
mod tests { mod tests {
use super::*; use super::*;
use try_from::TryFrom; use try_from::TryFrom;
use minidom::Element;
use std::str::FromStr; use std::str::FromStr;
#[test] #[test]

View file

@ -4,7 +4,6 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this // 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/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
use minidom::Element;
use jid::Jid; use jid::Jid;
use error::Error; use error::Error;
use ns; use ns;
@ -55,6 +54,7 @@ impl Stream {
mod tests { mod tests {
use super::*; use super::*;
use try_from::TryFrom; use try_from::TryFrom;
use minidom::Element;
#[test] #[test]
fn test_simple() { fn test_simple() {

View file

@ -4,7 +4,6 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this // 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/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
use minidom::Element;
use jid::Jid; use jid::Jid;
use error::Error; use error::Error;
use ns; use ns;
@ -55,6 +54,7 @@ impl Open {
mod tests { mod tests {
use super::*; use super::*;
use try_from::TryFrom; use try_from::TryFrom;
use minidom::Element;
#[test] #[test]
fn test_simple() { fn test_simple() {