From a96f175e9b2d8aba2e48a204249bbd4d9e0e3375 Mon Sep 17 00:00:00 2001 From: Jeremy Wall Date: Sat, 8 May 2021 15:01:20 -0400 Subject: [PATCH] Merge into DAO --- kitchen/src/api.rs | 4 +++- recipe-store/src/lib.rs | 2 +- recipes/src/lib.rs | 29 +++-------------------------- recipes/src/test.rs | 5 ----- 4 files changed, 7 insertions(+), 33 deletions(-) diff --git a/kitchen/src/api.rs b/kitchen/src/api.rs index 7e19cd2..612a47a 100644 --- a/kitchen/src/api.rs +++ b/kitchen/src/api.rs @@ -21,7 +21,9 @@ pub struct Api { } impl Api { - // mealplan + pub fn new_recipe_from_str(&self, input: &str) {} + + pub fn new_mealplan_from_str(&self, input: &str) {} } impl From for Api { diff --git a/recipe-store/src/lib.rs b/recipe-store/src/lib.rs index 1e30778..d21b54b 100644 --- a/recipe-store/src/lib.rs +++ b/recipe-store/src/lib.rs @@ -237,7 +237,7 @@ impl<'conn> TxHandle<'conn> { let id: Uuid = r.get(0)?; let title: String = r.get(1)?; let desc: String = r.get(2)?; - Ok(Recipe::new_id(id, title, desc)) + Ok(Recipe::new_with_id(id, title, desc)) } fn map_ingredient_row(r: &rusqlite::Row) -> Result { diff --git a/recipes/src/lib.rs b/recipes/src/lib.rs index 501ef2f..c720366 100644 --- a/recipes/src/lib.rs +++ b/recipes/src/lib.rs @@ -56,7 +56,7 @@ impl Mealplan { /// A Recipe with a title, description, and a series of steps. #[derive(Debug, Clone, PartialEq)] pub struct Recipe { - pub id: uuid::Uuid, // TODO(jwall): use uuid instead? + pub id: uuid::Uuid, pub title: String, pub desc: String, pub steps: Vec, @@ -72,7 +72,7 @@ impl Recipe { } } - pub fn new_id>(id: uuid::Uuid, title: S, desc: S) -> Self { + pub fn new_with_id>(id: uuid::Uuid, title: S, desc: S) -> Self { Self { id: id, title: title.into(), @@ -120,18 +120,6 @@ impl Recipe { } } -#[derive(Clone, Debug, PartialEq)] -pub struct StepKey(i64, i64); - -impl StepKey { - pub fn recipe_id(&self) -> i64 { - self.0 - } - pub fn step_idx(&self) -> i64 { - self.1 - } -} - /// A Recipe step. It has the time for the step if there is one, instructions, and an ingredients /// list. #[derive(Debug, Clone, PartialEq)] @@ -150,17 +138,6 @@ impl Step { } } - pub fn new_id>( - prep_time: Option, - instructions: S, - ) -> Self { - Self { - prep_time: prep_time, - instructions: instructions.into(), - ingredients: Vec::new(), - } - } - pub fn add_ingredients(&mut self, ingredients: Iter) where Iter: IntoIterator, @@ -200,7 +177,7 @@ impl Ingredient { } } - pub fn new_id>( + pub fn new_with_id>( id: i64, name: S, form: Option, diff --git a/recipes/src/test.rs b/recipes/src/test.rs index b04a304..1f61d21 100644 --- a/recipes/src/test.rs +++ b/recipes/src/test.rs @@ -233,8 +233,3 @@ fn test_ingredient_display() { assert_eq!(format!("{}", i), expected); } } - -#[test] -fn test_recipe_display() { - todo!() -}