Skip to main content

oak_xml/parser/
element_type.rs

1use oak_core::{ElementType, UniversalElementRole};
2
3/// XML element types.
4#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
5#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
6pub enum XmlElementType {
7    /// Root element.
8    Root,
9    /// Prolog.
10    Prolog,
11    /// Element.
12    Element,
13    /// Start tag.
14    StartTag,
15    /// End tag.
16    EndTag,
17    /// Self-closing tag.
18    SelfClosingTag,
19    /// Attribute.
20    Attribute,
21    /// Text content.
22    Text,
23    /// Comment.
24    Comment,
25    /// CDATA section.
26    CData,
27}
28
29impl ElementType for XmlElementType {
30    type Role = UniversalElementRole;
31
32    fn role(&self) -> Self::Role {
33        match self {
34            _ => UniversalElementRole::None,
35        }
36    }
37}
38
39impl From<crate::lexer::token_type::XmlTokenType> for XmlElementType {
40    fn from(token: crate::lexer::token_type::XmlTokenType) -> Self {
41        unsafe { std::mem::transmute(token) }
42    }
43}