2023-03-07 13:56:31 +00:00
|
|
|
use quick_xml::events::Event;
|
|
|
|
|
|
|
|
pub trait Parser: Sized {
|
|
|
|
type Output;
|
|
|
|
|
|
|
|
fn consume<'a>(self: Self, event: &Event<'a>) -> Continuation<Self, Self::Output>;
|
|
|
|
}
|
|
|
|
|
|
|
|
pub enum Continuation<Parser, Res> {
|
|
|
|
Final(Res),
|
|
|
|
Continue(Parser),
|
|
|
|
}
|
|
|
|
|
|
|
|
macro_rules! fail_fast {
|
|
|
|
($errorable: expr) => {
|
|
|
|
match $errorable {
|
|
|
|
Ok(i) => i,
|
2023-03-07 15:27:09 +00:00
|
|
|
Err(e) => return Continuation::Final(Err(e.into())),
|
2023-03-07 13:56:31 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2023-03-07 15:27:09 +00:00
|
|
|
pub(crate) use fail_fast;
|