1use std::fmt;
2
3#[derive(Debug)]
4pub enum Item {
5 Node { name: String, children: Vec<Item> },
6 Declaration(String, String),
7}
8
9impl fmt::Display for Item {
10 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
11 match self {
12 Item::Node { name, children } => {
13 write!(f, "{} {{", name)?;
14 for child in children.iter() {
15 write!(f, "{}", child)?;
16 }
17 write!(f, "}}")
18 }
19 Item::Declaration(key, value) => write!(f, "{}: {};", key, value),
20 }
21 }
22}
23
24#[derive(Debug)]
25pub struct Content {
26 pub items: Vec<Item>,
27}
28
29impl fmt::Display for Content {
30 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
31 for item in self.items.iter() {
32 write!(f, "{}", item)?;
33 }
34 Ok(())
35 }
36}