summaryrefslogtreecommitdiffstats
path: root/crates/common/src/types.rs
blob: f45d1ddf36bc6b64df547eeae7a741bbb6e27245 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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 Display for TaskID {
	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 inherit: Vec<LayerHash>,
	pub depends: HashSet<Dependency>,
	pub outputs: HashMap<String, String>,
}

#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct TaskOutput {
	pub input_hash: InputHash,
	pub layer: Option<LayerHash>,
	pub outputs: HashMap<String, ArchiveHash>,
}