From fc68a577575b06151b71720872a50b17323f65bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Sch=C3=A4fer?= Date: Fri, 9 Aug 2024 17:02:08 +0200 Subject: [PATCH] parsers: provide stub FromXml/AsXml implementations on Presence --- parsers/src/presence.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/parsers/src/presence.rs b/parsers/src/presence.rs index 35d0a564..6d51263d 100644 --- a/parsers/src/presence.rs +++ b/parsers/src/presence.rs @@ -370,6 +370,28 @@ impl From for Element { } } +impl ::xso::FromXml for Presence { + 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 != "presence" { + return Err(::xso::error::FromEventsError::Mismatch { name: qname, attrs }); + } + Self::Builder::new(qname, attrs) + } +} + +impl ::xso::AsXml for Presence { + 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::*;