From b931af3c25450d5cbb5ac6a0e893e58d75841e8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Sch=C3=A4fer?= Date: Fri, 9 Aug 2024 17:01:56 +0200 Subject: [PATCH] parsers: provide stub FromXml/AsXml implementations on Iq --- parsers/src/iq.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/parsers/src/iq.rs b/parsers/src/iq.rs index afd90a7cf3c1768feb5e11e3659710e57f623c76..edca5bb157af4c13bb489034963c735716efc3ec 100644 --- a/parsers/src/iq.rs +++ b/parsers/src/iq.rs @@ -223,6 +223,28 @@ impl From for Element { } } +impl ::xso::FromXml for Iq { + type Builder = ::xso::minidom_compat::FromEventsViaElement; + + fn from_events( + qname: ::xso::exports::rxml::QName, + attrs: ::xso::exports::rxml::AttrMap, + ) -> Result { + if qname.0 != crate::ns::DEFAULT_NS || qname.1 != "iq" { + return Err(::xso::error::FromEventsError::Mismatch { name: qname, attrs }); + } + Self::Builder::new(qname, attrs) + } +} + +impl ::xso::AsXml for Iq { + type ItemIter<'x> = ::xso::minidom_compat::AsItemsViaElement<'x>; + + fn as_xml_iter(&self) -> Result, ::xso::error::Error> { + ::xso::minidom_compat::AsItemsViaElement::new(self.clone()) + } +} + #[cfg(test)] mod tests { use super::*;