-struct Recipe {\r
- ingredients: Vec<Ingredient>,\r
- process: Vec<Group>,\r
+pub struct Recipe {\r
+ pub id: i32,\r
+ pub title: String,\r
+ pub description: Option<String>,\r
+ pub estimate_time: Option<i32>, // [min].\r
+ pub difficulty: Option<Difficulty>,\r
+\r
+ //ingredients: Vec<Ingredient>, // For four people.\r
+ pub process: Vec<Group>,\r
+}\r
+\r
+impl Recipe {\r
+ pub fn new(id: i32, title: String, description: Option<String>) -> Recipe {\r
+ Recipe {\r
+ id,\r
+ title,\r
+ description,\r
+ estimate_time: None,\r
+ difficulty: None,\r
+ process: Vec::new(),\r
+ }\r
+ }\r
}\r
\r
-struct Ingredient {\r
- quantity: Quantity,\r
- name: String,\r
+pub struct Ingredient {\r
+ pub quantity: Option<Quantity>,\r
+ pub name: String,\r
}\r
\r
-struct Quantity {\r
- value: f32,\r
- unit: String,\r
+pub struct Quantity {\r
+ pub value: f32,\r
+ pub unit: String,\r
}\r
-struct Group {\r
- name: String,\r
- steps: Vec<Step>,\r
+\r
+pub struct Group {\r
+ pub name: Option<String>,\r
+ pub steps: Vec<Step>,\r
}\r
\r
-struct Step {\r
- action: String,\r
- input: Vec<StepInput>,\r
- output: Vec<IntermediateSubstance>,\r
+pub struct Step {\r
+ pub action: String,\r
+ pub input: Vec<StepInput>,\r
+ pub output: Vec<IntermediateSubstance>,\r
}\r
\r
-struct IntermediateSubstance {\r
- name: String,\r
- quantity: Option<Quantity>,\r
+pub struct IntermediateSubstance {\r
+ pub name: String,\r
+ pub quantity: Option<Quantity>,\r
}\r
\r
-enum StepInput {\r
+pub enum StepInput {\r
Ingredient(Ingredient),\r
- IntermediateSubstance,\r
-}
\ No newline at end of file
+ IntermediateSubstance(IntermediateSubstance),\r
+}\r
+\r
+pub enum Difficulty {\r
+ Unknown,\r
+ Easy,\r
+ Medium,\r
+ Hard,\r
+}\r