mam: Improve serialisation.

This commit is contained in:
Emmanuel Gil Peyrot 2017-05-25 00:41:13 +01:00
parent a6b3152add
commit b4e47e9a78

View file

@ -188,18 +188,13 @@ impl TryFrom<Element> for Prefs {
impl Into<Element> for Query { impl Into<Element> for Query {
fn into(self) -> Element { fn into(self) -> Element {
let mut elem = Element::builder("query") Element::builder("query")
.ns(ns::MAM) .ns(ns::MAM)
.attr("queryid", self.queryid.clone()) .attr("queryid", self.queryid)
.attr("node", self.node.clone()) .attr("node", self.node)
.build(); //.append(self.form.map(|form| -> Element { form.into() }))
//if let Some(form) = self.form { .append(self.set.map(|set| -> Element { set.into() }))
// elem.append_child(form.into()); .build()
//}
if let Some(set) = self.set {
elem.append_child(set.into());
}
elem
} }
} }
@ -236,7 +231,7 @@ impl Into<Element> for Prefs {
let mut always = Element::builder("always") let mut always = Element::builder("always")
.ns(ns::RSM) .ns(ns::RSM)
.build(); .build();
for jid in self.always.clone() { for jid in self.always {
always.append_child(Element::builder("jid") always.append_child(Element::builder("jid")
.ns(ns::RSM) .ns(ns::RSM)
.append(String::from(jid)) .append(String::from(jid))
@ -248,7 +243,7 @@ impl Into<Element> for Prefs {
let mut never = Element::builder("never") let mut never = Element::builder("never")
.ns(ns::RSM) .ns(ns::RSM)
.build(); .build();
for jid in self.never.clone() { for jid in self.never {
never.append_child(Element::builder("jid") never.append_child(Element::builder("jid")
.ns(ns::RSM) .ns(ns::RSM)
.append(String::from(jid)) .append(String::from(jid))