oak_d2/parser/
element_type.rs1use crate::lexer::token_type::D2TokenType;
2use oak_core::{ElementType, UniversalElementRole};
3
4#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
6#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
7pub enum D2ElementType {
8 Token(D2TokenType),
10 Root,
12 Shape,
14 Connection,
16 Container,
18 Error,
20}
21
22impl From<D2TokenType> for D2ElementType {
23 fn from(token: D2TokenType) -> Self {
24 Self::Token(token)
25 }
26}
27
28impl ElementType for D2ElementType {
29 type Role = UniversalElementRole;
30
31 fn role(&self) -> Self::Role {
32 match self {
33 Self::Root => UniversalElementRole::Root,
34 _ => UniversalElementRole::None,
35 }
36 }
37}