move Repo and Recipe into the library
This commit is contained in:
parent
20c49c62a0
commit
57b8dae357
4 changed files with 84 additions and 62 deletions
62
tools/src/recipe.rs
Normal file
62
tools/src/recipe.rs
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
// #[derive(Debug, serde::Deserialize)]
|
||||
// enum Quantity {
|
||||
// Count(usize),
|
||||
// Amount(String),
|
||||
// }
|
||||
|
||||
#[derive(Debug, serde::Deserialize)]
|
||||
pub struct Input {
|
||||
/// Each input has either a `quantity` (for discrete things, like
|
||||
/// apples or bearings) or an `amount` (for continuous things,
|
||||
/// like rope or flour).
|
||||
///
|
||||
/// FIXME: Is there a good way to handle the "units" of the
|
||||
/// quantity/amount? Maybe the units could default to "count", but
|
||||
/// be optionally overridden by the recipe to things like "meters"
|
||||
/// (of tubing) or "grams" (of chromic acid). Then this struct
|
||||
/// would be `quantity: usize, units: Option<Unit>`.
|
||||
quantity: Option<usize>,
|
||||
amount: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize)]
|
||||
pub struct Operator {
|
||||
skills: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize)]
|
||||
pub struct Dependencies {
|
||||
tools: Vec<String>,
|
||||
operator: Operator,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize)]
|
||||
pub struct Action {
|
||||
process: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize)]
|
||||
pub struct Recipe {
|
||||
/// `[inputs]` is a Table where each key the the name (unique id)
|
||||
/// of a recipe in the repo, and the value is an Input object.
|
||||
inputs: std::collections::HashMap<String, Input>,
|
||||
|
||||
dependencies: Dependencies,
|
||||
|
||||
action: Action,
|
||||
|
||||
/// If a recipe has no `[outputs]`, we assume it produces 1x of the
|
||||
/// thing identified by the name of the recipe.
|
||||
///
|
||||
/// FIXME: Or is that always the case, and we should have no outputs
|
||||
/// section? None of the recipes we've been doodling around with
|
||||
/// have anything like byproducts or waste streams...
|
||||
outputs: Option<Vec<String>>,
|
||||
}
|
||||
|
||||
pub fn validate_recipe(recipe: &Recipe) -> anyhow::Result<()> {
|
||||
// if recipe.inputs.len() == 0 {
|
||||
// Err("recipe has no inputs!");
|
||||
// }
|
||||
Ok(())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue