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
|
use std::{collections::HashMap, fs::File, path::Path};
use serde::{Deserialize, Serialize};
use common::{error::*, string_hash::*};
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Args {
pub host: Option<String>,
pub target: Option<String>,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Provides {
pub recipe: String,
pub task: String,
pub output: Vec<String>,
pub args: Args,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
pub struct Pin {
pub hash: Option<ArchiveHash>,
#[serde(default)]
pub provides: Vec<Provides>,
#[serde(default)]
pub is_rootfs: bool,
}
pub type Pins = HashMap<String, Pin>;
pub fn read_pins<P: AsRef<Path>>(path: P) -> Result<Pins> {
let f = File::open(path)?;
let pins: Pins = serde_yaml::from_reader(f)
.map_err(Error::new)
.context("YAML error")?;
Ok(pins)
}
|