xmpp-parsers: Convert Forwarded to xso

This commit is contained in:
Emmanuel Gil Peyrot 2024-08-09 15:38:49 +02:00 committed by Jonas Schäfer
commit cb2c4133fe
4 changed files with 75 additions and 25 deletions

View file

@ -330,6 +330,28 @@ impl From<Message> for Element {
}
}
impl ::xso::FromXml for Message {
type Builder = ::xso::minidom_compat::FromEventsViaElement<Message>;
fn from_events(
qname: ::xso::exports::rxml::QName,
attrs: ::xso::exports::rxml::AttrMap,
) -> Result<Self::Builder, ::xso::error::FromEventsError> {
if qname.0 != crate::ns::DEFAULT_NS || qname.1 != "message" {
return Err(::xso::error::FromEventsError::Mismatch { name: qname, attrs });
}
Self::Builder::new(qname, attrs)
}
}
impl ::xso::AsXml for Message {
type ItemIter<'x> = ::xso::minidom_compat::AsItemsViaElement<'x>;
fn as_xml_iter(&self) -> Result<Self::ItemIter<'_>, ::xso::error::Error> {
::xso::minidom_compat::AsItemsViaElement::new(self.clone())
}
}
#[cfg(test)]
mod tests {
use super::*;