-struct Recipe {\r
- title: String,\r
- estimate_time: Option<i32>, // [min].\r
- difficulty: Option<Difficulty>,\r
+use chrono::prelude::*;\r
+\r
+pub struct User {\r
+ pub id: i64,\r
+ pub email: String,\r
+}\r
+\r
+pub struct UserLoginInfo {\r
+ pub last_login_datetime: DateTime<Utc>,\r
+ pub ip: String,\r
+ pub user_agent: String,\r
+}\r
+\r
+pub struct Recipe {\r
+ pub id: i64,\r
+ pub user_id: i64,\r
+ pub title: String,\r
+ pub description: String,\r
+ pub estimate_time: Option<i32>, // [min].\r
+ pub difficulty: Difficulty,\r
\r
//ingredients: Vec<Ingredient>, // For four people.\r
- process: Vec<Group>,\r
+ pub process: Vec<Group>,\r
+}\r
+\r
+impl Recipe {\r
+ pub fn empty(id: i64, user_id: i64) -> Recipe {\r
+ Self::new(id, user_id, String::new(), String::new())\r
+ }\r
+\r
+ pub fn new(id: i64, user_id: i64, title: String, description: String) -> Recipe {\r
+ Recipe {\r
+ id,\r
+ user_id,\r
+ title,\r
+ description,\r
+ estimate_time: None,\r
+ difficulty: Difficulty::Unknown,\r
+ process: Vec::new(),\r
+ }\r
+ }\r
}\r
\r
-struct Ingredient {\r
- quantity: Option<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
\r
-struct Group {\r
- name: Option<String>,\r
- steps: Vec<Step>,\r
+pub struct Group {\r
+ pub name: Option<String>,\r
+ pub input: Vec<StepInput>,\r
+ pub output: Vec<IntermediateSubstance>,\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
}\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(IntermediateSubstance),\r
}\r
\r
-enum Difficulty {\r
+pub enum Difficulty {\r
Unknown,\r
Easy,\r
Medium,\r