parsers: port more things to derive macros

This commit is contained in:
Jonas Schäfer 2024-08-03 13:04:56 +02:00
commit 2b346c4e87
18 changed files with 382 additions and 304 deletions

View file

@ -172,6 +172,20 @@ impl TryFrom<Element> for SetResult {
}
}
impl FromXml for SetResult {
type Builder = minidom_compat::FromEventsViaElement<SetResult>;
fn from_events(
qname: rxml::QName,
attrs: rxml::AttrMap,
) -> Result<Self::Builder, FromEventsError> {
if qname.0 != crate::ns::RSM || qname.1 != "set" {
return Err(FromEventsError::Mismatch { name: qname, attrs });
}
Self::Builder::new(qname, attrs)
}
}
impl From<SetResult> for Element {
fn from(set: SetResult) -> Element {
let first = set.first.clone().map(|first| {
@ -193,6 +207,14 @@ impl From<SetResult> for Element {
}
}
impl AsXml for SetResult {
type ItemIter<'x> = minidom_compat::AsItemsViaElement<'x>;
fn as_xml_iter(&self) -> Result<Self::ItemIter<'_>, Error> {
minidom_compat::AsItemsViaElement::new(self.clone())
}
}
#[cfg(test)]
mod tests {
use super::*;