Add frontend tests and other stuff
[recipes.git] / backend / src / model.rs
1 pub struct Recipe {
2 pub id: i64,
3 pub title: String,
4 pub description: Option<String>,
5 pub estimate_time: Option<i32>, // [min].
6 pub difficulty: Option<Difficulty>,
7
8 //ingredients: Vec<Ingredient>, // For four people.
9 pub process: Vec<Group>,
10 }
11
12 impl Recipe {
13 pub fn new(id: i64, title: String, description: Option<String>) -> Recipe {
14 Recipe {
15 id,
16 title,
17 description,
18 estimate_time: None,
19 difficulty: None,
20 process: Vec::new(),
21 }
22 }
23 }
24
25 pub struct Ingredient {
26 pub quantity: Option<Quantity>,
27 pub name: String,
28 }
29
30 pub struct Quantity {
31 pub value: f32,
32 pub unit: String,
33 }
34
35 pub struct Group {
36 pub name: Option<String>,
37 pub steps: Vec<Step>,
38 }
39
40 pub struct Step {
41 pub action: String,
42 pub input: Vec<StepInput>,
43 pub output: Vec<IntermediateSubstance>,
44 }
45
46 pub struct IntermediateSubstance {
47 pub name: String,
48 pub quantity: Option<Quantity>,
49 }
50
51 pub enum StepInput {
52 Ingredient(Ingredient),
53 IntermediateSubstance(IntermediateSubstance),
54 }
55
56 pub enum Difficulty {
57 Unknown,
58 Easy,
59 Medium,
60 Hard,
61 }