24 lines
657 B
Rust
24 lines
657 B
Rust
use crate::domain::{misc_types::Lang, recipe::types};
|
|
|
|
use super::ingredient::IngredientRepo;
|
|
|
|
pub trait RecipeRepo {
|
|
fn get_recipes(&self) -> Vec<types::Recipe>;
|
|
}
|
|
|
|
pub struct StaticRecipeRepo;
|
|
|
|
impl RecipeRepo for StaticRecipeRepo {
|
|
fn get_recipes(&self) -> Vec<types::Recipe> {
|
|
let ings_repo = crate::repo::ingredient::StaticIngredientRepo;
|
|
let ings = ings_repo.get_ingredients(Default::default());
|
|
|
|
let langs = [Lang::default()].repeat(db::RECIPES.len());
|
|
db::RECIPES
|
|
.iter()
|
|
.zip(langs)
|
|
.map(|(rec, lang)| From::from((rec, lang, ings.clone())))
|
|
.collect()
|
|
}
|
|
}
|