diff --git a/src/iq.rs b/src/iq.rs
index 87477c3e..eda650ac 100644
--- a/src/iq.rs
+++ b/src/iq.rs
@@ -8,11 +8,13 @@ use error::Error;
use ns;
use disco;
+use ping;
/// Lists every known payload of a ``.
#[derive(Debug, Clone)]
pub enum IqPayload {
Disco(disco::Disco),
+ Ping(ping::Ping),
}
#[derive(Debug, Clone)]
@@ -77,6 +79,8 @@ pub fn parse_iq(root: &Element) -> Result {
} else {
let parsed_payload = if let Ok(disco) = disco::parse_disco(elem) {
Some(IqPayload::Disco(disco))
+ } else if let Ok(ping) = ping::parse_ping(elem) {
+ Some(IqPayload::Ping(ping))
} else {
None
};
@@ -127,6 +131,7 @@ pub fn parse_iq(root: &Element) -> Result {
pub fn serialise_payload(payload: &IqPayload) -> Element {
match *payload {
IqPayload::Disco(ref disco) => disco::serialise_disco(disco),
+ IqPayload::Ping(_) => ping::serialise_ping(),
}
}
diff --git a/src/ping.rs b/src/ping.rs
index a8c94c50..1d5c89ac 100644
--- a/src/ping.rs
+++ b/src/ping.rs
@@ -18,6 +18,10 @@ pub fn parse_ping(root: &Element) -> Result {
Ok(Ping { })
}
+pub fn serialise_ping() -> Element {
+ Element::builder("ping").ns(ns::PING).build()
+}
+
#[cfg(test)]
mod tests {
use minidom::Element;