forked from lavina/lavina
23 lines
456 B
Rust
23 lines
456 B
Rust
|
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,
|
||
|
Err(e) => return Continuation::Final(Err(e.into()))
|
||
|
}
|
||
|
};
|
||
|
}
|
||
|
|
||
|
pub(crate) use fail_fast;
|