summaryrefslogtreecommitdiff
path: root/src/step.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/step.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/step.rs')
-rw-r--r--src/step.rs15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/step.rs b/src/step.rs
index 92b8eec..c37994a 100644
--- a/src/step.rs
+++ b/src/step.rs
@@ -1,4 +1,5 @@
use super::Status;
+use serde::Deserialize;
use std::fmt;
/// A roadmap step.
@@ -6,11 +7,16 @@ use std::fmt;
/// See the crate documentation for an example. You
/// probably don't want to create steps manually, but via the roadmap
/// YAML parsing function.
-#[derive(Clone, Debug, PartialEq, Eq)]
+#[derive(Clone, Debug, PartialEq, Eq, Deserialize)]
+#[serde(deny_unknown_fields)]
pub struct Step {
+ #[serde(skip)]
name: String,
- status: Status,
+ #[serde(default)]
label: String,
+ #[serde(default)]
+ status: Status,
+ #[serde(default)]
depends: Vec<String>,
}
@@ -25,6 +31,11 @@ impl Step {
}
}
+ /// Set the name of a step.
+ pub fn set_name(&mut self, name: &str) {
+ self.name = name.to_string();
+ }
+
/// Return the name of a step.
pub fn name(&self) -> &str {
&self.name