#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum LayoutEntry {
Empty,
Key (String),
Comment (String),
}
#[derive(Debug, Clone, PartialEq, PartialOrd)]
pub enum Value {
Empty,
I64 (i64),
F64 (f64),
Bool (bool),
String (String),
}
impl Value {
pub fn format(&self) -> String {
match self {
Self::Empty => String::from("empty"),
Self::I64 (i64_value) => i64_value.to_string(),
Self::F64 (f64_value) => f64_value.to_string(),
Self::Bool (true) => String::from("true"),
Self::Bool (false) => String::from("false"),
Self::String (string_value) => {
if string_value.contains("\n") {
let mut output = String::from("\"\n");
for line in string_value.split('\n') {
output.push('"');
output += line;
output.push('\n');
}
output
} else {
format!("\"{string_value}\"")
}
}
}
}
pub const fn type_as_string(&self) -> &'static str {
match self {
Self::Empty => "Empty",
Self::I64 (_) => "Int",
Self::F64 (_) => "Float",
Self::Bool (_) => "Bool",
Self::String (_) => "String",
}
}
pub const fn type_as_singular_string(&self) -> &'static str {
match self {
Self::Empty => "an Empty",
Self::I64 (_) => "an Int",
Self::F64 (_) => "a Float",
Self::Bool (_) => "a Bool",
Self::String (_) => "a String",
}
}
}
pub type DidRunUpdaters = bool;