forked from lavina/lavina
39 lines
1.1 KiB
Rust
39 lines
1.1 KiB
Rust
use super::*;
|
|
|
|
#[derive(Default, Debug, PartialEq, Eq)]
|
|
pub struct Ignore;
|
|
|
|
impl FromXml for Ignore {
|
|
type P = impl Parser<Output = Result<Self>>;
|
|
|
|
fn parse() -> Self::P {
|
|
|(mut namespace, mut event): (ResolveResult<'static>, &'static Event<'static>)| -> Result<Self> {
|
|
let mut depth = match event {
|
|
Event::Start(bytes) => 0,
|
|
Event::Empty(_) => return Ok(Ignore),
|
|
_ => return Ok(Ignore),
|
|
};
|
|
loop {
|
|
(namespace, event) = yield;
|
|
match event {
|
|
Event::End(_) => {
|
|
if depth == 0 {
|
|
return Ok(Ignore);
|
|
} else {
|
|
depth -= 1;
|
|
}
|
|
}
|
|
Event::Start(_) => {
|
|
depth += 1;
|
|
}
|
|
_ => (),
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
impl ToXml for () {
|
|
fn serialize(&self, _: &mut Vec<Event<'static>>) {}
|
|
}
|