diff options
author | Katharina Fey <kookie@spacekookie.de> | 2020-08-20 21:41:45 +0200 |
---|---|---|
committer | Katharina Fey <kookie@spacekookie.de> | 2020-08-20 21:41:45 +0200 |
commit | b4b9515fd969cb6445c8a93b7eb1ec8ebe529949 (patch) | |
tree | cacb2255f9dfba2f72738ffeab28e820f0422090 /rif/src/schema.rs | |
parent | f76b3008a69e376fac06a1c383936531748e654a (diff) |
rif: adding Recipes and Metadata
Diffstat (limited to 'rif/src/schema.rs')
-rw-r--r-- | rif/src/schema.rs | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/rif/src/schema.rs b/rif/src/schema.rs index df7b6b4..28c1304 100644 --- a/rif/src/schema.rs +++ b/rif/src/schema.rs @@ -1,22 +1,38 @@ use identity::Identity as Id; +use std::collections::BTreeSet; /// A schema format backing a recipe set -pub struct Schema { - ingredients: BTreeSet<Ingredient>, - worksteps: BTreeSet<Workstep>, +pub struct Schema<I, W> +where + I: Ingredient, + W: Workstep, +{ + /// Set of ingredients present in a recipe + pub ingredients: BTreeSet<I>, + /// Set of allowed work-steps in a recipe + pub worksteps: BTreeSet<W>, } /// A string-tagged ingredient in a recipe pub trait Ingredient { + /// Get a human readable ingredient name fn name(&self) -> String; + /// Get the ingredient slug fn slug(&self) -> String; + /// A machine-efficient, random ID fn id(&self) -> Id; } /// An execution step pub trait Workstep { + /// Get a human readable workstep name fn name(&self) -> String; + /// Get the workstep slug + fn slug(&self) -> String; + /// Get the human readable workstep description fn description(&self) -> String; + /// A machine-efficient, random ID fn id(&self) -> Id; - async fn run(&self) -> Option<()>; + /// Execute some custom code for the step + fn run(&self) -> Option<()>; } |