easy_configuration_format/
data.rs1#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
3pub enum LayoutEntry {
4 Empty,
6 Key (String),
8 Comment (String),
10}
11
12
13
14#[derive(Debug, Clone, PartialEq, PartialOrd)]
16pub enum Value {
17 Empty,
19 I64 (i64),
21 F64 (f64),
23 Bool (bool),
25 String (String),
27}
28
29impl Value {
30 pub fn format(&self) -> String {
32 match self {
33 Self::Empty => String::from("empty"),
34 Self::I64 (i64_value) => i64_value.to_string(),
35 Self::F64 (f64_value) => f64_value.to_string(),
36 Self::Bool (true) => String::from("true"),
37 Self::Bool (false) => String::from("false"),
38 Self::String (string_value) => {
39 if string_value.contains("\n") {
40 let mut output = String::from("\"\n");
41 for line in string_value.split('\n') {
42 output.push('"');
43 output += line;
44 output.push('\n');
45 }
46 output
47 } else {
48 format!("\"{string_value}\"")
49 }
50 }
51 }
52 }
53 pub const fn type_as_string(&self) -> &'static str {
55 match self {
56 Self::Empty => "Empty",
57 Self::I64 (_) => "Int",
58 Self::F64 (_) => "Float",
59 Self::Bool (_) => "Bool",
60 Self::String (_) => "String",
61 }
62 }
63 pub const fn type_as_singular_string(&self) -> &'static str {
65 match self {
66 Self::Empty => "an Empty",
67 Self::I64 (_) => "an Int",
68 Self::F64 (_) => "a Float",
69 Self::Bool (_) => "a Bool",
70 Self::String (_) => "a String",
71 }
72 }
73}
74
75
76
77pub type DidRunUpdaters = bool;