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