pub struct Database { /* private fields */ }Implementations§
Source§impl Database
impl Database
pub fn open(path: &Path) -> Result<Self>
pub fn open_in_memory() -> Result<Self>
pub fn insert_food(&self, food: &NewFood) -> Result<Food>
pub fn upsert_food_by_barcode(&self, food: &NewFood) -> Result<Food>
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_meal_entry(&self, entry: &NewMealEntry) -> Result<MealEntry>
pub fn get_meal_entry(&self, id: i64) -> Result<MealEntry>
pub fn delete_meal_entry(&self, id: i64) -> Result<bool>
pub fn update_meal_entry( &self, id: i64, update: &UpdateMealEntry, ) -> Result<MealEntry>
pub fn get_entries_for_date(&self, date: NaiveDate) -> Result<Vec<MealEntry>>
pub fn get_entries_for_date_and_meal( &self, date: NaiveDate, meal_type: &str, ) -> Result<Vec<MealEntry>>
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_by_id(&self, id: i64) -> Result<Recipe>
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 get_recipe_ingredients( &self, recipe_id: i64, ) -> Result<Vec<RecipeIngredient>>
pub fn get_recipe_detail(&self, recipe_id: i64) -> Result<RecipeDetail>
pub fn list_recipes(&self) -> Result<Vec<RecipeDetail>>
pub fn delete_recipe(&self, recipe_id: i64) -> Result<()>
pub fn record_tombstone(&self, uuid: &str, table_name: &str) -> Result<()>
pub fn get_tombstones(&self) -> Result<Vec<SyncTombstone>>
pub fn get_tombstones_since(&self, since: &str) -> Result<Vec<SyncTombstone>>
pub fn clear_tombstones(&self) -> Result<()>
pub fn get_foods_since(&self, since: &str) -> Result<Vec<Food>>
pub fn get_all_foods(&self) -> Result<Vec<Food>>
pub fn get_meal_entries_since( &self, since: &str, ) -> Result<Vec<ExportMealEntry>>
pub fn get_all_meal_entries_export(&self) -> Result<Vec<ExportMealEntry>>
pub fn get_recipes_since(&self, since: &str) -> Result<Vec<ExportRecipe>>
pub fn get_all_recipes_export(&self) -> Result<Vec<ExportRecipe>>
pub fn get_recipe_ingredients_since( &self, since: &str, ) -> Result<Vec<ExportRecipeIngredient>>
pub fn get_all_recipe_ingredients_export( &self, ) -> Result<Vec<ExportRecipeIngredient>>
pub fn get_targets_since(&self, since: &str) -> Result<Vec<ExportTarget>>
pub fn get_all_targets_export(&self) -> Result<Vec<ExportTarget>>
pub fn get_weight_entries_since( &self, since: &str, ) -> Result<Vec<ExportWeightEntry>>
pub fn get_all_weight_entries_export(&self) -> Result<Vec<ExportWeightEntry>>
pub fn changes_since( &self, since: Option<&str>, server_timestamp: &str, ) -> Result<SyncPayload>
pub fn apply_remote_changes( &self, foods: &[Food], meal_entries: &[ExportMealEntry], recipes: &[ExportRecipe], recipe_ingredients: &[ExportRecipeIngredient], targets: &[ExportTarget], weight_entries: &[ExportWeightEntry], tombstones: &[SyncTombstone], ) -> Result<()>
pub fn get_or_create_device_id(&self) -> Result<String>
pub fn get_food_by_uuid(&self, uuid: &str) -> Result<Option<Food>>
pub fn get_meal_entry_uuid(&self, id: i64) -> Result<Option<String>>
pub fn get_recipe_uuid(&self, id: i64) -> Result<Option<String>>
pub fn get_recipe_ingredient_uuids(&self, recipe_id: i64) -> Result<Vec<String>>
pub fn export_all(&self) -> Result<ExportData>
pub fn import_all(&self, data: &ExportData) -> Result<ImportSummary>
pub fn upsert_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, today: NaiveDate) -> Result<i64>
pub fn get_calorie_average(&self, days: i64) -> Result<f64>
pub fn set_setting(&self, key: &str, value: &str) -> Result<()>
pub fn get_setting(&self, key: &str) -> Result<Option<String>>
pub fn delete_setting(&self, key: &str) -> Result<bool>
pub fn build_daily_summary(&self, date: NaiveDate) -> Result<DailySummary>
Auto Trait Implementations§
impl !Freeze for Database
impl !RefUnwindSafe for Database
impl Send for Database
impl !Sync for Database
impl Unpin for Database
impl UnsafeUnpin for Database
impl !UnwindSafe for Database
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