1use std::fmt::Debug;
2
3use crate::{Header, ObjectKey};
4
5#[derive(Debug, Clone, PartialEq)]
6pub enum Value {
7 File(Header, Box<Value>),
8 Object(Vec<(ObjectKey, Value)>),
9 Array(Vec<Value>),
10 Flag(String, Box<Value>),
11 String(String),
12 MultilineString(String),
13 Number(f64),
14 Bool(bool),
15 Null,
16}
17
18impl Value {
19 pub fn is_file(&self) -> bool {
20 matches!(self, Value::File(_, _))
21 }
22
23 pub fn is_object(&self) -> bool {
24 matches!(self, Value::Object(_))
25 }
26
27 pub fn is_array(&self) -> bool {
28 matches!(self, Value::Array(_))
29 }
30
31 pub fn is_flag(&self) -> bool {
32 matches!(self, Value::Flag(_, _))
33 }
34
35 pub fn is_string(&self) -> bool {
36 matches!(self, Value::String(_))
37 }
38
39 pub fn is_multiline_string(&self) -> bool {
40 matches!(self, Value::MultilineString(_))
41 }
42
43 pub fn is_number(&self) -> bool {
44 matches!(self, Value::Number(_))
45 }
46
47 pub fn is_boolean(&self) -> bool {
48 matches!(self, Value::Bool(_))
49 }
50
51 pub fn is_null(&self) -> bool {
52 matches!(self, Value::Null)
53 }
54}