Drafting
This commit is contained in:
@@ -1,16 +1,7 @@
|
||||
mod meal;
|
||||
mod recipe;
|
||||
mod storage;
|
||||
mod importer;
|
||||
|
||||
pub use self::meal::Meal;
|
||||
|
||||
pub fn fetch_meals() -> Vec<Meal> {
|
||||
vec![
|
||||
Meal::new("Raclette".to_string(), 800),
|
||||
Meal::new("Soupe".to_string(), 400),
|
||||
]
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#[test]
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
|
||||
/// An individual ingredient
|
||||
pub struct Ingredient {
|
||||
name: String,
|
||||
}
|
||||
|
||||
impl Ingredient {
|
||||
|
||||
pub(super) fn new(name: String) -> Ingredient {
|
||||
Ingredient { name }
|
||||
}
|
||||
}
|
||||
|
||||
/// An ordered set of dishes
|
||||
#[derive(Debug,Clone)]
|
||||
pub struct Meal {
|
||||
name: String,
|
||||
nutritional_value: i32,
|
||||
}
|
||||
|
||||
impl Meal {
|
||||
pub(super) fn new(name: String, nutritional_value: i32) -> Meal {
|
||||
Meal { name, nutritional_value }
|
||||
}
|
||||
|
||||
pub fn nutritional_value(&self) -> i32 {
|
||||
self.nutritional_value
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
55
cookbook/src/recipe.rs
Normal file
55
cookbook/src/recipe.rs
Normal file
@@ -0,0 +1,55 @@
|
||||
|
||||
/// Tag associated with ingredients
|
||||
pub enum FoodTag {
|
||||
Viande,
|
||||
Poisson,
|
||||
Legume,
|
||||
}
|
||||
|
||||
/// Categories for recipe, to organize them for navigation and planning
|
||||
pub enum RecipeCategory {
|
||||
PetitDejeuner,
|
||||
Entree,
|
||||
Plat,
|
||||
Dessert,
|
||||
}
|
||||
|
||||
/// A collection of tags, to be improved
|
||||
type FoodTags = Vec<FoodTag>;
|
||||
|
||||
/// Nutritionnal values per 100g, to be improved
|
||||
#[derive(Default)]
|
||||
struct NutritionnalValues;
|
||||
|
||||
/// An individual ingredient
|
||||
#[derive(Default)]
|
||||
pub struct Ingredient {
|
||||
/// All known alias of a same ingredient
|
||||
alias: Vec<String>,
|
||||
/// Nutrionnal values per 100g
|
||||
nutrition: NutritionnalValues,
|
||||
/// Associated tags to constraint planning
|
||||
tags: FoodTags,
|
||||
}
|
||||
|
||||
impl Ingredient {
|
||||
|
||||
/// Builds a brand new ingredient with given name as first alias
|
||||
pub(super) fn new(name: String) -> Ingredient {
|
||||
Ingredient {
|
||||
alias: vec![name],
|
||||
..
|
||||
Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
/// Find an existing ingredient by alias
|
||||
pub fn find(alias: &str) -> Option<Ingredient> {
|
||||
None
|
||||
}
|
||||
|
||||
/// Get the ingredient most common name
|
||||
pub fn name(&self) -> &str {
|
||||
self.alias.first().expect("Ingredient without any name !")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user