1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
use crate::prelude::{
Style,
Value,
};
#[derive(Debug, Clone, PartialEq)]
pub enum AttributeValue {
FunctionCall(Value),
Simple(Value),
Style(Vec<Style>),
Empty,
}
impl AttributeValue {
pub fn from_styles(styles: Vec<Style>) -> Self {
AttributeValue::Style(styles)
}
pub fn from_value(value: Value) -> Self {
AttributeValue::Simple(value)
}
pub fn function_call(value: Value) -> Self {
AttributeValue::FunctionCall(value)
}
pub fn get_simple(&self) -> Option<&Value> {
match self {
AttributeValue::Simple(v) => Some(&v),
_ => None,
}
}
pub fn get_function_call_value(&self) -> Option<&Value> {
match self {
AttributeValue::FunctionCall(v) => Some(&v),
_ => None,
}
}
pub fn is_style(&self) -> bool {
match self {
AttributeValue::Style(_) => true,
_ => false,
}
}
pub fn as_style(&self) -> Option<&Vec<Style>> {
match self {
AttributeValue::Style(styles) => Some(styles),
_ => None,
}
}
pub fn is_function_call(&self) -> bool {
match self {
AttributeValue::FunctionCall(_) => true,
_ => false,
}
}
pub fn is_empty(&self) -> bool {
match self {
AttributeValue::Empty => true,
_ => false,
}
}
}