use quick_xml::events::Event; use quick_xml::name::ResolveResult; use crate::prelude::Result; pub trait FromXml: Sized { type P: Parser>; fn parse() -> Self::P; } pub trait ToXml: Sized { fn serialize(&self, events: &mut Vec>); } pub trait Parser: Sized { type Output; fn consume<'a>( self: Self, namespace: ResolveResult, event: &Event<'a>, ) -> Continuation; } pub enum Continuation { Final(Res), Continue(Parser), } macro_rules! fail_fast { ($errorable: expr) => { match $errorable { Ok(i) => i, Err(e) => return Continuation::Final(Err(e.into())), } }; } pub(crate) use fail_fast;