Add some data access methods to Connection
This commit is contained in:
parent
4fbc599d07
commit
cdb883c3c4
6 changed files with 180 additions and 114 deletions
|
|
@ -1,44 +1,57 @@
|
|||
struct Recipe {
|
||||
title: String,
|
||||
estimate_time: Option<i32>, // [min].
|
||||
difficulty: Option<Difficulty>,
|
||||
pub struct Recipe {
|
||||
pub id: i32,
|
||||
pub title: String,
|
||||
pub estimate_time: Option<i32>, // [min].
|
||||
pub difficulty: Option<Difficulty>,
|
||||
|
||||
//ingredients: Vec<Ingredient>, // For four people.
|
||||
process: Vec<Group>,
|
||||
pub process: Vec<Group>,
|
||||
}
|
||||
|
||||
struct Ingredient {
|
||||
quantity: Option<Quantity>,
|
||||
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<Quantity>,
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
struct Group {
|
||||
name: Option<String>,
|
||||
steps: Vec<Step>,
|
||||
pub struct Quantity {
|
||||
pub value: f32,
|
||||
pub unit: String,
|
||||
}
|
||||
|
||||
struct Step {
|
||||
action: String,
|
||||
input: Vec<StepInput>,
|
||||
output: Vec<IntermediateSubstance>,
|
||||
pub struct Group {
|
||||
pub name: Option<String>,
|
||||
pub steps: Vec<Step>,
|
||||
}
|
||||
|
||||
struct IntermediateSubstance {
|
||||
name: String,
|
||||
quantity: Option<Quantity>,
|
||||
pub struct Step {
|
||||
pub action: String,
|
||||
pub input: Vec<StepInput>,
|
||||
pub output: Vec<IntermediateSubstance>,
|
||||
}
|
||||
|
||||
enum StepInput {
|
||||
pub struct IntermediateSubstance {
|
||||
pub name: String,
|
||||
pub quantity: Option<Quantity>,
|
||||
}
|
||||
|
||||
pub enum StepInput {
|
||||
Ingredient(Ingredient),
|
||||
IntermediateSubstance(IntermediateSubstance),
|
||||
}
|
||||
|
||||
enum Difficulty {
|
||||
pub enum Difficulty {
|
||||
Unknown,
|
||||
Easy,
|
||||
Medium,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue