Detailed changes
@@ -271,18 +271,15 @@ impl From<DataForm> for Element {
form.title
.map(|title| Element::builder("title", ns::DATA_FORMS).append(title)),
)
- .append_all(form.instructions.map(|text| {
- Element::builder("instructions", ns::DATA_FORMS)
- .append(text)
- }))
+ .append_all(
+ form.instructions
+ .map(|text| Element::builder("instructions", ns::DATA_FORMS).append(text)),
+ )
.append_all(form.form_type.map(|form_type| {
Element::builder("field", ns::DATA_FORMS)
.attr("var", "FORM_TYPE")
.attr("type", "hidden")
- .append(
- Element::builder("value", ns::DATA_FORMS)
- .append(form_type),
- )
+ .append(Element::builder("value", ns::DATA_FORMS).append(form_type))
}))
.append_all(form.fields.iter().cloned().map(Element::from))
.build()
@@ -434,25 +434,28 @@ impl FromStr for Reason {
impl From<Reason> for Element {
fn from(reason: Reason) -> Element {
- Element::builder(match reason {
- Reason::AlternativeSession => "alternative-session",
- Reason::Busy => "busy",
- Reason::Cancel => "cancel",
- Reason::ConnectivityError => "connectivity-error",
- Reason::Decline => "decline",
- Reason::Expired => "expired",
- Reason::FailedApplication => "failed-application",
- Reason::FailedTransport => "failed-transport",
- Reason::GeneralError => "general-error",
- Reason::Gone => "gone",
- Reason::IncompatibleParameters => "incompatible-parameters",
- Reason::MediaError => "media-error",
- Reason::SecurityError => "security-error",
- Reason::Success => "success",
- Reason::Timeout => "timeout",
- Reason::UnsupportedApplications => "unsupported-applications",
- Reason::UnsupportedTransports => "unsupported-transports",
- }, ns::JINGLE)
+ Element::builder(
+ match reason {
+ Reason::AlternativeSession => "alternative-session",
+ Reason::Busy => "busy",
+ Reason::Cancel => "cancel",
+ Reason::ConnectivityError => "connectivity-error",
+ Reason::Decline => "decline",
+ Reason::Expired => "expired",
+ Reason::FailedApplication => "failed-application",
+ Reason::FailedTransport => "failed-transport",
+ Reason::GeneralError => "general-error",
+ Reason::Gone => "gone",
+ Reason::IncompatibleParameters => "incompatible-parameters",
+ Reason::MediaError => "media-error",
+ Reason::SecurityError => "security-error",
+ Reason::Success => "success",
+ Reason::Timeout => "timeout",
+ Reason::UnsupportedApplications => "unsupported-applications",
+ Reason::UnsupportedTransports => "unsupported-transports",
+ },
+ ns::JINGLE,
+ )
.build()
}
}
@@ -852,12 +855,10 @@ mod tests {
name: ContentId(String::from("this-is-a-stub")),
senders: Senders::default(),
description: Some(Description::Unknown(
- Element::builder("description", "urn:xmpp:jingle:apps:stub:0")
- .build(),
+ Element::builder("description", "urn:xmpp:jingle:apps:stub:0").build(),
)),
transport: Some(Transport::Unknown(
- Element::builder("transport", "urn:xmpp:jingle:transports:stub:0")
- .build(),
+ Element::builder("transport", "urn:xmpp:jingle:transports:stub:0").build(),
)),
security: None,
}],
@@ -194,20 +194,28 @@ impl TryFrom<Element> for File {
impl From<File> for Element {
fn from(file: File) -> Element {
Element::builder("file", ns::JINGLE_FT)
- .append_all(file.date.map(|date| Element::builder("date", ns::JINGLE_FT).append(date)))
.append_all(
- file.media_type
- .map(|media_type| Element::builder("media-type", ns::JINGLE_FT).append(media_type)),
+ file.date
+ .map(|date| Element::builder("date", ns::JINGLE_FT).append(date)),
+ )
+ .append_all(
+ file.media_type.map(|media_type| {
+ Element::builder("media-type", ns::JINGLE_FT).append(media_type)
+ }),
+ )
+ .append_all(
+ file.name
+ .map(|name| Element::builder("name", ns::JINGLE_FT).append(name)),
)
- .append_all(file.name.map(|name| Element::builder("name", ns::JINGLE_FT).append(name)))
.append_all(file.descs.into_iter().map(|(lang, desc)| {
Element::builder("desc", ns::JINGLE_FT)
.attr("xml:lang", lang)
.append(desc.0)
}))
.append_all(
- file.size
- .map(|size| Element::builder("size", ns::JINGLE_FT).append(format!("{}", size))),
+ file.size.map(|size| {
+ Element::builder("size", ns::JINGLE_FT).append(format!("{}", size))
+ }),
)
.append_all(file.range)
.append_all(file.hashes)
@@ -85,22 +85,19 @@ impl TryFrom<Element> for JingleMI {
impl From<JingleMI> for Element {
fn from(jingle_mi: JingleMI) -> Element {
match jingle_mi {
- JingleMI::Propose { sid, description } =>
+ JingleMI::Propose { sid, description } => {
Element::builder("propose", ns::JINGLE_MESSAGE)
- .attr("id", sid)
- .append(description),
- JingleMI::Retract(sid) =>
- Element::builder("retract", ns::JINGLE_MESSAGE)
- .attr("id", sid),
- JingleMI::Accept(sid) =>
- Element::builder("accept", ns::JINGLE_MESSAGE)
- .attr("id", sid),
- JingleMI::Proceed(sid) =>
- Element::builder("proceed", ns::JINGLE_MESSAGE)
- .attr("id", sid),
- JingleMI::Reject(sid) =>
- Element::builder("reject", ns::JINGLE_MESSAGE)
- .attr("id", sid),
+ .attr("id", sid)
+ .append(description)
+ }
+ JingleMI::Retract(sid) => {
+ Element::builder("retract", ns::JINGLE_MESSAGE).attr("id", sid)
+ }
+ JingleMI::Accept(sid) => Element::builder("accept", ns::JINGLE_MESSAGE).attr("id", sid),
+ JingleMI::Proceed(sid) => {
+ Element::builder("proceed", ns::JINGLE_MESSAGE).attr("id", sid)
+ }
+ JingleMI::Reject(sid) => Element::builder("reject", ns::JINGLE_MESSAGE).attr("id", sid),
}
.build()
}
@@ -251,17 +251,19 @@ impl From<Transport> for Element {
.into_iter()
.map(Element::from)
.collect::<Vec<_>>(),
- TransportPayload::Activated(cid) => vec![
- Element::builder("activated", ns::JINGLE_S5B)
+ TransportPayload::Activated(cid) => {
+ vec![Element::builder("activated", ns::JINGLE_S5B)
.attr("cid", cid)
- .build()],
- TransportPayload::CandidateError => vec![
- Element::builder("candidate-error", ns::JINGLE_S5B)
- .build()],
- TransportPayload::CandidateUsed(cid) => vec![
- Element::builder("candidate-used", ns::JINGLE_S5B)
+ .build()]
+ }
+ TransportPayload::CandidateError => {
+ vec![Element::builder("candidate-error", ns::JINGLE_S5B).build()]
+ }
+ TransportPayload::CandidateUsed(cid) => {
+ vec![Element::builder("candidate-used", ns::JINGLE_S5B)
.attr("cid", cid)
- .build()],
+ .build()]
+ }
TransportPayload::ProxyError => {
vec![Element::builder("proxy-error", ns::JINGLE_S5B).build()]
}
@@ -167,10 +167,10 @@ fn serialise_jid_list(name: &str, jids: Vec<Jid>) -> ::std::option::IntoIter<Nod
} else {
Some(
Element::builder(name, ns::MAM)
- .append_all(jids.into_iter().map(|jid| {
- Element::builder("jid", ns::MAM)
- .append(String::from(jid))
- }))
+ .append_all(
+ jids.into_iter()
+ .map(|jid| Element::builder("jid", ns::MAM).append(String::from(jid))),
+ )
.into(),
)
.into_iter()
@@ -365,11 +365,17 @@ mod tests {
let elem: Element = SetNick::new("coucou").into();
let xml = String::from(&elem);
- assert_eq!(xml, "<setnick xmlns=\"urn:xmpp:mix:core:1\"><nick>coucou</nick></setnick>");
+ assert_eq!(
+ xml,
+ "<setnick xmlns=\"urn:xmpp:mix:core:1\"><nick>coucou</nick></setnick>"
+ );
let elem: Element = Mix::new("coucou", "coucou@example").into();
let xml = String::from(&elem);
- assert_eq!(xml, "<mix xmlns=\"urn:xmpp:mix:core:1\"><nick>coucou</nick><jid>coucou@example</jid></mix>");
+ assert_eq!(
+ xml,
+ "<mix xmlns=\"urn:xmpp:mix:core:1\"><nick>coucou</nick><jid>coucou@example</jid></mix>"
+ );
let elem: Element = Create::new().into();
let xml = String::from(&elem);
@@ -324,8 +324,10 @@ impl From<Presence> for Element {
.append_all(if presence.priority == 0 {
None
} else {
- Some(Element::builder("priority", ns::DEFAULT_NS)
- .append(format!("{}", presence.priority)))
+ Some(
+ Element::builder("priority", ns::DEFAULT_NS)
+ .append(format!("{}", presence.priority)),
+ )
})
.append_all(presence.payloads.into_iter())
.build()
@@ -195,31 +195,33 @@ impl TryFrom<Element> for PubSubEvent {
impl From<PubSubEvent> for Element {
fn from(event: PubSubEvent) -> Element {
let payload = match event {
- PubSubEvent::Configuration { node, form } =>
+ PubSubEvent::Configuration { node, form } => {
Element::builder("configuration", ns::PUBSUB_EVENT)
.attr("node", node)
- .append_all(form.map(Element::from)),
- PubSubEvent::Delete { node, redirect } =>
- Element::builder("purge", ns::PUBSUB_EVENT)
+ .append_all(form.map(Element::from))
+ }
+ PubSubEvent::Delete { node, redirect } => Element::builder("purge", ns::PUBSUB_EVENT)
.attr("node", node)
.append_all(redirect.map(|redirect| {
- Element::builder("redirect", ns::PUBSUB_EVENT)
- .attr("uri", redirect)
+ Element::builder("redirect", ns::PUBSUB_EVENT).attr("uri", redirect)
})),
- PubSubEvent::PublishedItems { node, items } =>
+ PubSubEvent::PublishedItems { node, items } => {
Element::builder("items", ns::PUBSUB_EVENT)
.attr("node", node)
- .append_all(items.into_iter()),
- PubSubEvent::RetractedItems { node, items } =>
+ .append_all(items.into_iter())
+ }
+ PubSubEvent::RetractedItems { node, items } => {
Element::builder("items", ns::PUBSUB_EVENT)
.attr("node", node)
- .append_all(items.into_iter().map(|id| {
- Element::builder("retract", ns::PUBSUB_EVENT)
- .attr("id", id)
- })),
- PubSubEvent::Purge { node } =>
- Element::builder("purge", ns::PUBSUB_EVENT)
- .attr("node", node),
+ .append_all(
+ items
+ .into_iter()
+ .map(|id| Element::builder("retract", ns::PUBSUB_EVENT).attr("id", id)),
+ )
+ }
+ PubSubEvent::Purge { node } => {
+ Element::builder("purge", ns::PUBSUB_EVENT).attr("node", node)
+ }
PubSubEvent::Subscription {
node,
expiry,
@@ -71,10 +71,10 @@ impl TryFrom<Element> for SetQuery {
impl From<SetQuery> for Element {
fn from(set: SetQuery) -> Element {
Element::builder("set", ns::RSM)
- .append_all(set.max.map(|max| {
- Element::builder("max", ns::RSM)
- .append(format!("{}", max))
- }))
+ .append_all(
+ set.max
+ .map(|max| Element::builder("max", ns::RSM).append(format!("{}", max))),
+ )
.append_all(
set.after
.map(|after| Element::builder("after", ns::RSM).append(after)),
@@ -83,10 +83,10 @@ impl From<SetQuery> for Element {
set.before
.map(|before| Element::builder("before", ns::RSM).append(before)),
)
- .append_all(set.index.map(|index| {
- Element::builder("index", ns::RSM)
- .append(format!("{}", index))
- }))
+ .append_all(
+ set.index
+ .map(|index| Element::builder("index", ns::RSM).append(format!("{}", index))),
+ )
.build()
}
}
@@ -157,10 +157,10 @@ impl From<SetResult> for Element {
set.last
.map(|last| Element::builder("last", ns::RSM).append(last)),
)
- .append_all(set.count.map(|count| {
- Element::builder("count", ns::RSM)
- .append(format!("{}", count))
- }))
+ .append_all(
+ set.count
+ .map(|count| Element::builder("count", ns::RSM).append(format!("{}", count))),
+ )
.build()
}
}
@@ -580,8 +580,7 @@ macro_rules! generate_serialiser {
};
($builder:ident, $parent:ident, $elem:ident, Option, String, ($name:tt, $ns:ident)) => {
$builder.append_all($parent.$elem.map(|elem| {
- crate::Element::builder($name, crate::ns::$ns)
- .append(::minidom::Node::Text(elem))
+ crate::Element::builder($name, crate::ns::$ns).append(::minidom::Node::Text(elem))
}))
};
($builder:ident, $parent:ident, $elem:ident, Option, $constructor:ident, ($name:tt, *)) => {
@@ -454,8 +454,7 @@ impl From<Tag> for Element {
panic!("No unknown element should be present in XHTML-IM after parsing.")
}
};
- let mut builder = Element::builder(name, ns::XHTML)
- .append_all(children_to_nodes(children));
+ let mut builder = Element::builder(name, ns::XHTML).append_all(children_to_nodes(children));
for (key, value) in attrs {
builder = builder.attr(key, value);
}