diff --git a/Cargo.toml b/Cargo.toml index c5ff5e09..c1f48c00 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,6 @@ license = "MPL-2.0" [dependencies] minidom = "0.4.4" -jid = "0.2.0" base64 = "0.6.0" digest = "0.6.0" sha-1 = "0.4.0" @@ -23,3 +22,7 @@ sha3 = "0.6.0" blake2 = "0.6.1" chrono = "0.4.0" try_from = "0.2.2" + +[dependencies.jid] +version = "0.2.3" +features = ["minidom"] diff --git a/src/delay.rs b/src/delay.rs index e5123ec2..97c10ad7 100644 --- a/src/delay.rs +++ b/src/delay.rs @@ -49,7 +49,7 @@ impl From for Element { fn from(delay: Delay) -> Element { Element::builder("delay") .ns(ns::DELAY) - .attr("from", delay.from.map(String::from)) + .attr("from", delay.from) .attr("stamp", delay.stamp.to_rfc3339()) .append(delay.data) .build() diff --git a/src/disco.rs b/src/disco.rs index b976e362..b1d21680 100644 --- a/src/disco.rs +++ b/src/disco.rs @@ -307,7 +307,7 @@ impl From for Element { fn from(item: Item) -> Element { Element::builder("item") .ns(ns::DISCO_ITEMS) - .attr("jid", String::from(item.jid)) + .attr("jid", item.jid) .attr("node", item.node) .attr("name", item.name) .build() diff --git a/src/iq.rs b/src/iq.rs index 2584ebeb..1fd308c0 100644 --- a/src/iq.rs +++ b/src/iq.rs @@ -276,8 +276,8 @@ impl From for Element { fn from(iq: Iq) -> Element { let mut stanza = Element::builder("iq") .ns(ns::JABBER_CLIENT) - .attr("from", iq.from.map(String::from)) - .attr("to", iq.to.map(String::from)) + .attr("from", iq.from) + .attr("to", iq.to) .attr("id", iq.id) .attr("type", &iq.payload) .build(); diff --git a/src/jingle.rs b/src/jingle.rs index 364ee4b8..d36d0862 100644 --- a/src/jingle.rs +++ b/src/jingle.rs @@ -298,8 +298,8 @@ impl From for Element { Element::builder("jingle") .ns(ns::JINGLE) .attr("action", jingle.action) - .attr("initiator", match jingle.initiator { Some(initiator) => Some(String::from(initiator)), None => None }) - .attr("responder", match jingle.responder { Some(responder) => Some(String::from(responder)), None => None }) + .attr("initiator", jingle.initiator) + .attr("responder", jingle.responder) .attr("sid", jingle.sid) .append(jingle.contents) .append(jingle.reason) diff --git a/src/message.rs b/src/message.rs index 80a0e044..3bf73ae8 100644 --- a/src/message.rs +++ b/src/message.rs @@ -211,8 +211,8 @@ impl From for Element { fn from(message: Message) -> Element { Element::builder("message") .ns(ns::JABBER_CLIENT) - .attr("from", message.from.map(String::from)) - .attr("to", message.to.map(String::from)) + .attr("from", message.from) + .attr("to", message.to) .attr("id", message.id) .attr("type", message.type_) .append(message.subjects.into_iter() diff --git a/src/muc/user.rs b/src/muc/user.rs index afc9e721..9e141ad2 100644 --- a/src/muc/user.rs +++ b/src/muc/user.rs @@ -186,7 +186,7 @@ impl From for Element { let elem = Element::builder("actor").ns(ns::MUC_USER); (match actor { - Actor::Jid(jid) => elem.attr("jid", String::from(jid)), + Actor::Jid(jid) => elem.attr("jid", jid), Actor::Nick(nick) => elem.attr("nick", nick), }).build() } @@ -330,10 +330,7 @@ impl From for Element { Element::builder("item") .ns(ns::MUC_USER) .attr("affiliation", item.affiliation) - .attr("jid", match item.jid { - Some(jid) => Some(String::from(jid)), - None => None, - }) + .attr("jid", item.jid) .attr("nick", item.nick) .attr("role", item.role) .append(item.actor) diff --git a/src/presence.rs b/src/presence.rs index 93c5cf94..958a82b3 100644 --- a/src/presence.rs +++ b/src/presence.rs @@ -317,8 +317,8 @@ impl From for Element { fn from(presence: Presence) -> Element { Element::builder("presence") .ns(ns::JABBER_CLIENT) - .attr("from", presence.from.map(String::from)) - .attr("to", presence.to.map(String::from)) + .attr("from", presence.from) + .attr("to", presence.to) .attr("id", presence.id) .attr("type", presence.type_) .append(presence.show) diff --git a/src/pubsub/event.rs b/src/pubsub/event.rs index a6fa4550..108d0ab1 100644 --- a/src/pubsub/event.rs +++ b/src/pubsub/event.rs @@ -31,7 +31,7 @@ impl From for Element { .ns(ns::PUBSUB_EVENT) .attr("id", item.id) .attr("node", item.node) - .attr("publisher", item.publisher.map(String::from)) + .attr("publisher", item.publisher) .append(item.payload) .build() } @@ -255,7 +255,7 @@ impl From for Element { .ns(ns::PUBSUB_EVENT) .attr("node", node) .attr("expiry", expiry.map(|expiry| expiry.to_rfc3339())) - .attr("jid", jid.map(String::from)) + .attr("jid", jid) .attr("subid", subid) .attr("subscription", subscription) .build() diff --git a/src/roster.rs b/src/roster.rs index 82488a34..9e2bba31 100644 --- a/src/roster.rs +++ b/src/roster.rs @@ -74,7 +74,7 @@ impl From for Element { fn from(item: Item) -> Element { Element::builder("item") .ns(ns::ROSTER) - .attr("jid", String::from(item.jid)) + .attr("jid", item.jid) .attr("name", item.name) .attr("subscription", item.subscription) .append(item.groups) diff --git a/src/stanza_error.rs b/src/stanza_error.rs index 3b7273b3..0c7ca7e8 100644 --- a/src/stanza_error.rs +++ b/src/stanza_error.rs @@ -177,7 +177,7 @@ impl From for Element { let mut root = Element::builder("error") .ns(ns::JABBER_CLIENT) .attr("type", err.type_) - .attr("by", err.by.map(String::from)) + .attr("by", err.by) .append(err.defined_condition) .build(); for (lang, text) in err.texts { diff --git a/src/stanza_id.rs b/src/stanza_id.rs index 43ce9645..feeeadbe 100644 --- a/src/stanza_id.rs +++ b/src/stanza_id.rs @@ -41,7 +41,7 @@ impl From for Element { Element::builder("stanza-id") .ns(ns::SID) .attr("id", stanza_id.id) - .attr("by", String::from(stanza_id.by)) + .attr("by", stanza_id.by) .build() } }