2023-03-20 16:25:14 +00:00
|
|
|
use super::*;
|
|
|
|
|
|
|
|
#[derive(Default, Debug, PartialEq, Eq)]
|
|
|
|
pub struct Ignore;
|
|
|
|
|
2024-04-16 15:44:34 +00:00
|
|
|
impl FromXml for Ignore {
|
|
|
|
type P = impl Parser<Output = Result<Self>>;
|
2023-03-20 16:25:14 +00:00
|
|
|
|
2024-04-16 15:44:34 +00:00
|
|
|
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;
|
2023-03-20 16:25:14 +00:00
|
|
|
}
|
2024-04-16 15:44:34 +00:00
|
|
|
_ => (),
|
2023-03-20 16:25:14 +00:00
|
|
|
}
|
2024-04-16 15:44:34 +00:00
|
|
|
}
|
2023-03-20 16:25:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl ToXml for () {
|
2023-10-04 13:55:34 +00:00
|
|
|
fn serialize(&self, _: &mut Vec<Event<'static>>) {}
|
2023-03-20 16:25:14 +00:00
|
|
|
}
|