Upgrade to minidom 0.4.4 to avoid having to redefine IntoElements for each Into<Element>.

This commit is contained in:
Emmanuel Gil Peyrot 2017-07-21 01:20:29 +01:00
parent 21cee25b27
commit 3b6733f38b
9 changed files with 9 additions and 105 deletions

View file

@ -13,7 +13,7 @@ categories = ["parsing", "network-programming"]
license = "MPL-2.0" license = "MPL-2.0"
[dependencies] [dependencies]
minidom = "0.4.3" minidom = "0.4.4"
jid = "0.2.0" jid = "0.2.0"
base64 = "0.6.0" base64 = "0.6.0"
digest = "0.6.0" digest = "0.6.0"

View file

@ -7,7 +7,7 @@
use try_from::TryFrom; use try_from::TryFrom;
use std::str::FromStr; use std::str::FromStr;
use minidom::{Element, IntoElements, IntoAttributeValue, ElementEmitter}; use minidom::{Element, IntoAttributeValue};
use error::Error; use error::Error;
use ns; use ns;
@ -46,12 +46,6 @@ impl From<Option_> for Element {
} }
} }
impl IntoElements for Option_ {
fn into_elements(self, emitter: &mut ElementEmitter) {
emitter.append_child(self.into());
}
}
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct Field { pub struct Field {
pub var: String, pub var: String,
@ -80,12 +74,6 @@ impl From<Field> for Element {
} }
} }
impl IntoElements for Field {
fn into_elements(self, emitter: &mut ElementEmitter) {
emitter.append_child(self.into());
}
}
generate_attribute!(DataFormType, "type", { generate_attribute!(DataFormType, "type", {
Cancel => "cancel", Cancel => "cancel",
Form => "form", Form => "form",
@ -236,12 +224,6 @@ impl From<DataForm> for Element {
} }
} }
impl IntoElements for DataForm {
fn into_elements(self, emitter: &mut ElementEmitter) {
emitter.append_child(self.into());
}
}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;

View file

@ -6,7 +6,7 @@
use try_from::TryFrom; use try_from::TryFrom;
use minidom::{Element, IntoElements, ElementEmitter}; use minidom::Element;
use error::Error; use error::Error;
use ns; use ns;
@ -62,12 +62,6 @@ impl From<Feature> for Element {
} }
} }
impl IntoElements for Feature {
fn into_elements(self, emitter: &mut ElementEmitter) {
emitter.append_child(self.into());
}
}
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct Identity { pub struct Identity {
pub category: String, // TODO: use an enum here. pub category: String, // TODO: use an enum here.
@ -88,12 +82,6 @@ impl From<Identity> for Element {
} }
} }
impl IntoElements for Identity {
fn into_elements(self, emitter: &mut ElementEmitter) {
emitter.append_child(self.into());
}
}
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct DiscoInfoResult { pub struct DiscoInfoResult {
pub node: Option<String>, pub node: Option<String>,

View file

@ -7,7 +7,7 @@
use std::collections::HashMap; use std::collections::HashMap;
use try_from::TryFrom; use try_from::TryFrom;
use minidom::{Element, IntoElements, ElementEmitter}; use minidom::Element;
use error::Error; use error::Error;
@ -78,12 +78,6 @@ impl From<Query> for Element {
} }
} }
impl IntoElements for Query {
fn into_elements(self, emitter: &mut ElementEmitter) {
emitter.append_child(self.into());
}
}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;

View file

@ -7,7 +7,7 @@
use try_from::TryFrom; use try_from::TryFrom;
use std::str::FromStr; use std::str::FromStr;
use minidom::{Element, IntoElements, IntoAttributeValue, ElementEmitter}; use minidom::{Element, IntoAttributeValue};
use jid::Jid; use jid::Jid;
use error::Error; use error::Error;
@ -110,12 +110,6 @@ impl From<Content> for Element {
} }
} }
impl IntoElements for Content {
fn into_elements(self, emitter: &mut ElementEmitter) {
emitter.append_child(self.into());
}
}
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq)]
pub enum Reason { pub enum Reason {
AlternativeSession, //(String), AlternativeSession, //(String),
@ -240,12 +234,6 @@ impl From<ReasonElement> for Element {
} }
} }
impl IntoElements for ReasonElement {
fn into_elements(self, emitter: &mut ElementEmitter) {
emitter.append_child(self.into());
}
}
generate_id!(SessionId); generate_id!(SessionId);
#[derive(Debug, Clone)] #[derive(Debug, Clone)]

View file

@ -6,7 +6,7 @@
use try_from::TryFrom; use try_from::TryFrom;
use minidom::{Element, IntoElements, ElementEmitter}; use minidom::Element;
use error::Error; use error::Error;
@ -28,12 +28,6 @@ impl From<URI> for Element {
} }
} }
impl IntoElements for URI {
fn into_elements(self, emitter: &mut ElementEmitter) {
emitter.append_child(self.into());
}
}
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct MediaElement { pub struct MediaElement {
pub width: Option<usize>, pub width: Option<usize>,
@ -81,12 +75,6 @@ impl From<MediaElement> for Element {
} }
} }
impl IntoElements for MediaElement {
fn into_elements(self, emitter: &mut ElementEmitter) {
emitter.append_child(self.into());
}
}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;

View file

@ -8,7 +8,7 @@
use try_from::{TryFrom, TryInto}; use try_from::{TryFrom, TryInto};
use std::str::FromStr; use std::str::FromStr;
use minidom::{Element, IntoElements, IntoAttributeValue, ElementEmitter}; use minidom::{Element, IntoAttributeValue};
use jid::Jid; use jid::Jid;
@ -142,12 +142,6 @@ impl From<Status> for Element {
} }
} }
impl IntoElements for Status {
fn into_elements(self, emitter: &mut ElementEmitter) {
emitter.append_child(self.into());
}
}
/// Optional <actor/> element used in <item/> elements inside presence stanzas of type /// Optional <actor/> element used in <item/> elements inside presence stanzas of type
/// "unavailable" that are sent to users who are kick or banned, as well as within IQs for tracking /// "unavailable" that are sent to users who are kick or banned, as well as within IQs for tracking
/// purposes. -- CHANGELOG 0.17 (2002-10-23) /// purposes. -- CHANGELOG 0.17 (2002-10-23)
@ -198,12 +192,6 @@ impl From<Actor> for Element {
} }
} }
impl IntoElements for Actor {
fn into_elements(self, emitter: &mut ElementEmitter) {
emitter.append_child(self.into());
}
}
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq)]
pub struct Continue { pub struct Continue {
thread: Option<String>, thread: Option<String>,
@ -237,12 +225,6 @@ impl From<Continue> for Element {
} }
} }
impl IntoElements for Continue {
fn into_elements(self, emitter: &mut ElementEmitter) {
emitter.append_child(self.into());
}
}
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq)]
pub struct Reason(String); pub struct Reason(String);
@ -272,12 +254,6 @@ impl From<Reason> for Element {
} }
} }
impl IntoElements for Reason {
fn into_elements(self, emitter: &mut ElementEmitter) {
emitter.append_child(self.into());
}
}
generate_attribute!(Affiliation, "affiliation", { generate_attribute!(Affiliation, "affiliation", {
Owner => "owner", Owner => "owner",
Admin => "admin", Admin => "admin",

View file

@ -7,7 +7,7 @@
use try_from::TryFrom; use try_from::TryFrom;
use std::str::FromStr; use std::str::FromStr;
use minidom::{Element, IntoElements, IntoAttributeValue, ElementEmitter}; use minidom::{Element, IntoAttributeValue};
use jid::Jid; use jid::Jid;
use chrono::{DateTime, FixedOffset}; use chrono::{DateTime, FixedOffset};
@ -37,12 +37,6 @@ impl From<Item> for Element {
} }
} }
impl IntoElements for Item {
fn into_elements(self, emitter: &mut ElementEmitter) {
emitter.append_child(self.into());
}
}
generate_attribute!(Subscription, "subscription", { generate_attribute!(Subscription, "subscription", {
None => "none", None => "none",
Pending => "pending", Pending => "pending",

View file

@ -7,7 +7,7 @@
use try_from::TryFrom; use try_from::TryFrom;
use std::str::FromStr; use std::str::FromStr;
use minidom::{Element, IntoElements, IntoAttributeValue, ElementEmitter}; use minidom::{Element, IntoAttributeValue};
use jid::Jid; use jid::Jid;
use error::Error; use error::Error;
@ -70,12 +70,6 @@ impl From<Item> for Element {
} }
} }
impl IntoElements for Item {
fn into_elements(self, emitter: &mut ElementEmitter) {
emitter.append_child(self.into());
}
}
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct Roster { pub struct Roster {
pub ver: Option<String>, pub ver: Option<String>,