summaryrefslogtreecommitdiffstats
path: root/crates/rebel-common/src/types.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/rebel-common/src/types.rs')
-rw-r--r--crates/rebel-common/src/types.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/crates/rebel-common/src/types.rs b/crates/rebel-common/src/types.rs
index 2a06275..d3beb70 100644
--- a/crates/rebel-common/src/types.rs
+++ b/crates/rebel-common/src/types.rs
@@ -13,8 +13,29 @@ pub struct TaskID {
pub task: String,
}
+impl TaskID {
+ pub fn as_ref(&self) -> TaskIDRef<'_> {
+ TaskIDRef {
+ recipe: &self.recipe,
+ task: &self.task,
+ }
+ }
+}
+
impl Display for TaskID {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ self.as_ref().fmt(f)
+ }
+}
+
+#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
+pub struct TaskIDRef<'a> {
+ pub recipe: &'a str,
+ pub task: &'a str,
+}
+
+impl<'a> Display for TaskIDRef<'a> {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}::{}", self.recipe, self.task)
}
}