diff options
Diffstat (limited to 'crates/rebel-common/src/types.rs')
-rw-r--r-- | crates/rebel-common/src/types.rs | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/crates/rebel-common/src/types.rs b/crates/rebel-common/src/types.rs new file mode 100644 index 0000000..d3beb70 --- /dev/null +++ b/crates/rebel-common/src/types.rs @@ -0,0 +1,75 @@ +use std::{ + collections::{HashMap, HashSet}, + fmt::Display, +}; + +use serde::{Deserialize, Serialize}; + +use crate::string_hash::*; + +#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq, Hash)] +pub struct TaskID { + pub recipe: String, + 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) + } +} + +#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq, Hash)] +#[serde(rename_all = "snake_case")] +pub enum Dependency { + Fetch { + name: String, + target_dir: String, + sha256: StringHash, + }, + Task { + output: ArchiveHash, + path: String, + }, +} + +#[derive(Clone, Debug, Deserialize, Serialize)] +pub struct Task { + pub label: String, + pub command: String, + pub workdir: String, + pub rootfs: ArchiveHash, + pub ancestors: Vec<LayerHash>, + pub depends: HashSet<Dependency>, + pub outputs: HashMap<String, String>, + pub pins: HashMap<ArchiveHash, String>, + pub force_run: bool, +} + +#[derive(Clone, Debug, Deserialize, Serialize, Default)] +pub struct TaskOutput { + pub input_hash: Option<InputHash>, + pub layer: Option<LayerHash>, + pub outputs: HashMap<String, ArchiveHash>, +} |