use std::path::PathBuf;
#[derive(Debug, Clone)]
#[allow(missing_docs)]
pub enum Property {
String(String),
Int(i32),
Float(f64),
Bool(bool),
Color([u8; 4]),
File(String),
}
impl Property {
pub fn as_str(&self) -> Option<&str> {
match self {
Property::String(x) => Some(x.as_str()),
_ => None,
}
}
pub fn as_int(&self) -> Option<i32> {
match *self {
Property::Int(x) => Some(x),
Property::Float(x) => Some(x as i32),
_ => None,
}
}
pub fn as_float(&self) -> Option<f64> {
match *self {
Property::Float(x) => Some(x),
Property::Int(x) => Some(x as f64),
_ => None,
}
}
pub fn as_bool(&self) -> Option<bool> {
match *self {
Property::Bool(x) => Some(x),
_ => None,
}
}
pub fn as_color(&self) -> Option<[u8; 4]> {
match *self {
Property::Color(x) => Some(x),
_ => None,
}
}
pub fn as_file(&self) -> Option<PathBuf> {
match self {
Property::File(x) => Some(PathBuf::from(x)),
_ => None,
}
}
}