summaryrefslogtreecommitdiff
path: root/src/status.rs
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2022-01-21 09:34:47 +0200
committerLars Wirzenius <liw@liw.fi>2022-01-21 10:09:41 +0200
commitf49a7c9eaa14ce1aaf342d862ec292b84fa2e7bc (patch)
treee81eb68c3626715c541644e9055c2bd8c709fee9 /src/status.rs
parent82073da80b0f38d605204e96bf4b430c2b785813 (diff)
downloadroadmap-f49a7c9eaa14ce1aaf342d862ec292b84fa2e7bc.tar.gz
refactor: parse with serde directly to data structure
Use serde to parse directly to a hashmap of steps, instead of generic YAML values. This gives us better error messages. Sponsored-by: author
Diffstat (limited to 'src/status.rs')
-rw-r--r--src/status.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/status.rs b/src/status.rs
index 9075377..811d1ca 100644
--- a/src/status.rs
+++ b/src/status.rs
@@ -1,3 +1,5 @@
+use serde::Deserialize;
+
/// Represent the status of a step in a roadmap.
///
/// The unknown status allows the user to not specify the status, and
@@ -5,7 +7,8 @@
/// example, a step is inferred to be blocked if any of it
/// dependencies are not finished.
-#[derive(Clone, Copy, Debug, Eq, PartialEq)]
+#[derive(Clone, Copy, Debug, Eq, PartialEq, Deserialize)]
+#[serde(rename_all = "lowercase")]
pub enum Status {
Unknown,
Goal,
@@ -15,6 +18,12 @@ pub enum Status {
Blocked,
}
+impl Default for Status {
+ fn default() -> Self {
+ Self::Unknown
+ }
+}
+
impl Status {
pub fn from_text(text: &str) -> Option<Status> {
match text {