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