html_outliner/
sectioning_type.rs1#[derive(Debug, Copy, Clone, Eq, PartialEq)]
2pub enum SectioningType {
3 Article,
5 Aside,
6 Nav,
7 Section,
8
9 Root,
11 Body,
12 Heading,
13}
14
15impl SectioningType {
16 #[inline]
17 pub(crate) fn is_sectioning_content_type(&self) -> bool {
18 matches!(
19 self,
20 SectioningType::Article
21 | SectioningType::Aside
22 | SectioningType::Nav
23 | SectioningType::Section
24 )
25 }
26
27 #[inline]
28 pub(crate) fn is_heading(&self) -> bool {
29 matches!(self, SectioningType::Heading)
30 }
31
32 #[inline]
33 pub fn from_sectioning_content_tag<S: AsRef<str>>(s: S) -> Option<SectioningType> {
34 let s = s.as_ref();
35
36 match s {
37 "article" => Some(SectioningType::Article),
38 "aside" => Some(SectioningType::Aside),
39 "nav" => Some(SectioningType::Nav),
40 "section" => Some(SectioningType::Section),
41 _ => None,
42 }
43 }
44
45 #[inline]
46 pub fn as_str(&self) -> &'static str {
47 match self {
48 SectioningType::Article => "article",
49 SectioningType::Aside => "aside",
50 SectioningType::Nav => "nav",
51 SectioningType::Section => "section",
52 SectioningType::Root => "root",
53 SectioningType::Body => "body",
54 SectioningType::Heading => "heading",
55 }
56 }
57}