From c462d230f19bba7c44d32229408d6c7fd9b778a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Sun, 23 Apr 2017 21:17:26 +0100 Subject: [PATCH] ping, iq: Implement ping::serialise_ping and link to Iq. --- src/iq.rs | 5 +++++ src/ping.rs | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/src/iq.rs b/src/iq.rs index 87477c3..eda650a 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 a8c94c5..1d5c89a 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;