diff --git a/cookbook/src/lib.rs b/cookbook/src/lib.rs index f95df84..30c1801 100644 --- a/cookbook/src/lib.rs +++ b/cookbook/src/lib.rs @@ -1,16 +1,7 @@ -mod meal; +mod recipe; mod storage; mod importer; -pub use self::meal::Meal; - -pub fn fetch_meals() -> Vec { - vec![ - Meal::new("Raclette".to_string(), 800), - Meal::new("Soupe".to_string(), 400), - ] -} - #[cfg(test)] mod tests { #[test] diff --git a/cookbook/src/meal.rs b/cookbook/src/meal.rs deleted file mode 100644 index 9e1c4da..0000000 --- a/cookbook/src/meal.rs +++ /dev/null @@ -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 - } -} - - diff --git a/cookbook/src/recipe.rs b/cookbook/src/recipe.rs new file mode 100644 index 0000000..fb0cec9 --- /dev/null +++ b/cookbook/src/recipe.rs @@ -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; + +/// 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, + /// 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 { + None + } + + /// Get the ingredient most common name + pub fn name(&self) -> &str { + self.alias.first().expect("Ingredient without any name !") + } +}