xml_data/parser/
ignore.rs

1use crate::{
2	parser::{
3		ElementState,
4		ElementParser,
5	},
6	Result,
7};
8use std::borrow::Cow;
9
10/// Can be used as `ElementState` to ignore an element with all content (attributes and sub
11/// elements and text)
12pub struct IgnoreElement;
13
14impl ElementState for IgnoreElement {
15	type Output = ();
16
17	fn parse_element_start(_tag: &str) -> Option<Self> {
18		Some(Self)
19	}
20
21	fn parse_element_attribute(&mut self, _key: &str, _value: Cow<'_, str>) -> Result<()> {
22		Ok(())
23	}
24
25	fn parse_element_inner_text(&mut self, _text: Cow<'_, str>) -> Result<()> {
26		Ok(())
27	}
28
29	fn parse_element_inner_node<P: ElementParser>(&mut self, _tag: &str, parser: P) -> Result<()> {
30		// no need to create a new `IgnoreElement` state, just reuse `self`
31		parser.parse_element_state(self)
32	}
33
34	fn parse_element_finish(self) -> Result<Self::Output> {
35		Ok(())
36	}
37}