pub struct GrubService { /* private fields */ }Implementations§
Source§impl GrubService
impl GrubService
pub fn new(db_path: &str) -> Result<Self>
pub fn new_in_memory() -> Result<Self>
pub fn get_daily_summary(&self, date: &str) -> Result<DailySummary>
pub fn log_meal( &self, date: &str, meal_type: &str, food_id: i64, serving_g: f64, ) -> Result<MealEntry>
pub fn log_meal_with_display( &self, date: &str, meal_type: &str, food_id: i64, serving_g: f64, display_unit: Option<String>, display_quantity: Option<f64>, ) -> Result<MealEntry>
pub fn delete_meal(&self, id: i64) -> Result<bool>
pub fn update_meal( &self, id: i64, update: &UpdateMealEntry, ) -> Result<MealEntry>
pub fn get_meal_entry(&self, id: i64) -> Result<MealEntry>
pub fn get_food_by_id(&self, id: i64) -> Result<Food>
pub fn get_food_by_barcode(&self, barcode: &str) -> Result<Option<Food>>
pub fn search_foods_local(&self, query: &str) -> Result<Vec<Food>>
pub fn list_foods(&self, search: Option<&str>) -> Result<Vec<Food>>
pub fn insert_food(&self, food: &NewFood) -> Result<Food>
pub fn upsert_food_by_barcode(&self, food: &NewFood) -> Result<Food>
pub fn set_target( &self, day_of_week: i64, calories: i64, protein_pct: Option<i64>, carbs_pct: Option<i64>, fat_pct: Option<i64>, ) -> Result<DailyTarget>
pub fn get_target(&self, day_of_week: i64) -> Result<Option<DailyTarget>>
pub fn get_all_targets(&self) -> Result<Vec<DailyTarget>>
pub fn clear_target(&self, day_of_week: i64) -> Result<bool>
pub fn clear_all_targets(&self) -> Result<bool>
pub fn create_recipe(&self, name: &str, portions: f64) -> Result<Recipe>
pub fn get_recipe_detail(&self, recipe_id: i64) -> Result<RecipeDetail>
pub fn get_recipe_by_food_name(&self, name: &str) -> Result<Recipe>
pub fn add_recipe_ingredient( &self, recipe_id: i64, food_id: i64, quantity_g: f64, ) -> Result<RecipeIngredient>
pub fn remove_recipe_ingredient( &self, recipe_id: i64, food_name: &str, ) -> Result<bool>
pub fn set_recipe_portions(&self, recipe_id: i64, portions: f64) -> Result<()>
pub fn list_recipes(&self) -> Result<Vec<RecipeDetail>>
pub fn delete_recipe(&self, recipe_id: i64) -> Result<()>
pub fn log_weight(&self, entry: &NewWeightEntry) -> Result<WeightEntry>
pub fn get_weight(&self, date: NaiveDate) -> Result<Option<WeightEntry>>
pub fn get_weight_history(&self, days: Option<i64>) -> Result<Vec<WeightEntry>>
pub fn delete_weight(&self, id: i64) -> Result<()>
pub fn get_recently_logged_foods(&self, limit: i64) -> Result<Vec<RecentFood>>
pub fn get_logging_streak(&self) -> Result<i64>
pub fn get_calorie_average(&self, days: i64) -> Result<f64>
pub fn set_goal_weight(&self, kg: f64) -> Result<()>
pub fn get_goal_weight(&self) -> Result<Option<f64>>
pub fn clear_goal_weight(&self) -> Result<bool>
Sourcepub fn search_and_cache(
&self,
provider: &dyn FoodLookupProvider,
query: &str,
) -> Result<Vec<Food>>
pub fn search_and_cache( &self, provider: &dyn FoodLookupProvider, query: &str, ) -> Result<Vec<Food>>
Search local DB first, then call the provider for remote results, cache them, and return a deduplicated list.
Sourcepub fn barcode_lookup(
&self,
provider: &dyn FoodLookupProvider,
code: &str,
) -> Result<Option<Food>>
pub fn barcode_lookup( &self, provider: &dyn FoodLookupProvider, code: &str, ) -> Result<Option<Food>>
Look up a barcode: check local cache first, then call the provider, cache and return.
pub fn get_device_id(&self) -> Result<String>
pub fn clear_tombstones(&self) -> Result<()>
pub fn changes_since(&self, since: Option<&str>) -> Result<SyncPayload>
pub fn apply_remote_changes( &self, request: &SyncPushRequest, ) -> Result<SyncPayload>
pub fn import_mfp_csv( &self, csv_data: &str, dry_run: bool, ) -> Result<MfpImportSummary>
pub fn export_all(&self) -> Result<ExportData>
pub fn import_all(&self, data: &ExportData) -> Result<ImportSummary>
Auto Trait Implementations§
impl !Freeze for GrubService
impl !RefUnwindSafe for GrubService
impl Send for GrubService
impl !Sync for GrubService
impl Unpin for GrubService
impl UnsafeUnpin for GrubService
impl !UnwindSafe for GrubService
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more