From 99b9525e6fde72f0e392e28370ea13663d7b92d6 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Sat, 29 Jul 2017 06:28:20 +0100 Subject: [PATCH] Update to jid-rs 0.2.3, which implements IntoAttributeValue on Jid. --- Cargo.toml | 5 ++++- src/delay.rs | 2 +- src/disco.rs | 2 +- src/iq.rs | 4 ++-- src/jingle.rs | 4 ++-- src/message.rs | 4 ++-- src/muc/user.rs | 7 ++----- src/presence.rs | 4 ++-- src/pubsub/event.rs | 4 ++-- src/roster.rs | 2 +- src/stanza_error.rs | 2 +- src/stanza_id.rs | 2 +- 12 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c5ff5e0..c1f48c0 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 e5123ec..97c10ad 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 b976e36..b1d2168 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 2584ebe..1fd308c 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 364ee4b..d36d086 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 80a0e04..3bf73ae 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 afc9e72..9e141ad 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 93c5cf9..958a82b 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 a6fa455..108d0ab 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 82488a3..9e2bba3 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 3b7273b..0c7ca7e 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 43ce964..feeeadb 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() } }