X-Git-Url: http://git.euphorik.ch/?p=recipes.git;a=blobdiff_plain;f=backend%2Fsrc%2Fmodel.rs;fp=backend%2Fsrc%2Fmodel.rs;h=4984cdd6844d42625a7ad45a2c105ca36471d355;hp=d012bc9b99ce8233ab61de0b6919e89f38459433;hb=cdb883c3c4ccbb82774ecfbfad059f3392e75432;hpb=4fbc599d074180920b20ee46e80cc0d3669a4129 diff --git a/backend/src/model.rs b/backend/src/model.rs index d012bc9..4984cdd 100644 --- a/backend/src/model.rs +++ b/backend/src/model.rs @@ -1,44 +1,57 @@ -struct Recipe { - title: String, - estimate_time: Option, // [min]. - difficulty: Option, +pub struct Recipe { + pub id: i32, + pub title: String, + pub estimate_time: Option, // [min]. + pub difficulty: Option, //ingredients: Vec, // For four people. - process: Vec, + pub process: Vec, } -struct Ingredient { - quantity: Option, - name: String, +impl Recipe { + pub fn new(id: i32, title: String) -> Recipe { + Recipe { + id, + title, + estimate_time: None, + difficulty: None, + process: Vec::new(), + } + } } -struct Quantity { - value: f32, - unit: String, +pub struct Ingredient { + pub quantity: Option, + pub name: String, } -struct Group { - name: Option, - steps: Vec, +pub struct Quantity { + pub value: f32, + pub unit: String, } -struct Step { - action: String, - input: Vec, - output: Vec, +pub struct Group { + pub name: Option, + pub steps: Vec, } -struct IntermediateSubstance { - name: String, - quantity: Option, +pub struct Step { + pub action: String, + pub input: Vec, + pub output: Vec, } -enum StepInput { +pub struct IntermediateSubstance { + pub name: String, + pub quantity: Option, +} + +pub enum StepInput { Ingredient(Ingredient), IntermediateSubstance(IntermediateSubstance), } -enum Difficulty { +pub enum Difficulty { Unknown, Easy, Medium,