80 lines
1.6 KiB
Rust
80 lines
1.6 KiB
Rust
use chrono::prelude::*;
|
|
|
|
pub struct User {
|
|
pub id: i64,
|
|
pub email: String,
|
|
}
|
|
|
|
pub struct UserLoginInfo {
|
|
pub last_login_datetime: DateTime<Utc>,
|
|
pub ip: String,
|
|
pub user_agent: String,
|
|
}
|
|
|
|
pub struct Recipe {
|
|
pub id: i64,
|
|
pub user_id: i64,
|
|
pub title: String,
|
|
pub description: String,
|
|
pub estimate_time: Option<i32>, // [min].
|
|
pub difficulty: Difficulty,
|
|
|
|
//ingredients: Vec<Ingredient>, // For four people.
|
|
pub process: Vec<Group>,
|
|
}
|
|
|
|
impl Recipe {
|
|
pub fn empty(id: i64, user_id: i64) -> Recipe {
|
|
Self::new(id, user_id, String::new(), String::new())
|
|
}
|
|
|
|
pub fn new(id: i64, user_id: i64, title: String, description: String) -> Recipe {
|
|
Recipe {
|
|
id,
|
|
user_id,
|
|
title,
|
|
description,
|
|
estimate_time: None,
|
|
difficulty: Difficulty::Unknown,
|
|
process: Vec::new(),
|
|
}
|
|
}
|
|
}
|
|
|
|
pub struct Ingredient {
|
|
pub quantity: Option<Quantity>,
|
|
pub name: String,
|
|
}
|
|
|
|
pub struct Quantity {
|
|
pub value: f32,
|
|
pub unit: String,
|
|
}
|
|
|
|
pub struct Group {
|
|
pub name: Option<String>,
|
|
pub input: Vec<StepInput>,
|
|
pub output: Vec<IntermediateSubstance>,
|
|
pub steps: Vec<Step>,
|
|
}
|
|
|
|
pub struct Step {
|
|
pub action: String,
|
|
}
|
|
|
|
pub struct IntermediateSubstance {
|
|
pub name: String,
|
|
pub quantity: Option<Quantity>,
|
|
}
|
|
|
|
pub enum StepInput {
|
|
Ingredient(Ingredient),
|
|
IntermediateSubstance(IntermediateSubstance),
|
|
}
|
|
|
|
pub enum Difficulty {
|
|
Unknown,
|
|
Easy,
|
|
Medium,
|
|
Hard,
|
|
}
|