1use std::path::PathBuf;
2
3#[derive(Debug, Clone)]
5#[allow(missing_docs)]
6pub enum Property {
7 String(String),
8 Int(i32),
9 Float(f64),
10 Bool(bool),
11 Color([u8; 4]),
13 File(String),
14}
15
16impl Property {
17 pub fn as_str(&self) -> Option<&str> {
19 match self {
20 Property::String(x) => Some(x.as_str()),
21 _ => None,
22 }
23 }
24
25 pub fn as_int(&self) -> Option<i32> {
27 match *self {
28 Property::Int(x) => Some(x),
29 Property::Float(x) => Some(x as i32),
30 _ => None,
31 }
32 }
33
34 pub fn as_float(&self) -> Option<f64> {
36 match *self {
37 Property::Float(x) => Some(x),
38 Property::Int(x) => Some(x as f64),
39 _ => None,
40 }
41 }
42
43 pub fn as_bool(&self) -> Option<bool> {
45 match *self {
46 Property::Bool(x) => Some(x),
47 _ => None,
48 }
49 }
50
51 pub fn as_color(&self) -> Option<[u8; 4]> {
53 match *self {
54 Property::Color(x) => Some(x),
55 _ => None,
56 }
57 }
58
59 pub fn as_file(&self) -> Option<PathBuf> {
61 match self {
62 Property::File(x) => Some(PathBuf::from(x)),
63 _ => None,
64 }
65 }
66}