pub struct MacroFactorClient {
pub auth: FirebaseAuth,
pub firestore: FirestoreClient,
/* private fields */
}Fields§
§auth: FirebaseAuth§firestore: FirestoreClientImplementations§
Source§impl MacroFactorClient
impl MacroFactorClient
pub fn new(refresh_token: String) -> Self
Sourcepub async fn login(email: &str, password: &str) -> Result<Self>
pub async fn login(email: &str, password: &str) -> Result<Self>
Sign in with email and password.
pub async fn get_user_id(&mut self) -> Result<String>
Sourcepub async fn get_profile(&mut self) -> Result<Value>
pub async fn get_profile(&mut self) -> Result<Value>
Get the user profile document.
Sourcepub async fn list_subcollections(
&self,
document_path: &str,
) -> Result<Vec<String>>
pub async fn list_subcollections( &self, document_path: &str, ) -> Result<Vec<String>>
List sub-collections under the user document.
Sourcepub async fn sample_collection(
&self,
collection_path: &str,
limit: u32,
) -> Result<Vec<Value>>
pub async fn sample_collection( &self, collection_path: &str, limit: u32, ) -> Result<Vec<Value>>
Get a few documents from a collection for schema discovery.
Sourcepub async fn get_raw_document(&self, path: &str) -> Result<Value>
pub async fn get_raw_document(&self, path: &str) -> Result<Value>
Get a raw document by path and return parsed fields.
Sourcepub async fn get_weight_entries(
&mut self,
start: NaiveDate,
end: NaiveDate,
) -> Result<Vec<ScaleEntry>>
pub async fn get_weight_entries( &mut self, start: NaiveDate, end: NaiveDate, ) -> Result<Vec<ScaleEntry>>
Get scale/weight entries for a date range.
Data is stored in scale/{year} docs with MMDD keys.
Sourcepub async fn get_nutrition(
&mut self,
start: NaiveDate,
end: NaiveDate,
) -> Result<Vec<NutritionSummary>>
pub async fn get_nutrition( &mut self, start: NaiveDate, end: NaiveDate, ) -> Result<Vec<NutritionSummary>>
Get nutrition summaries for a date range.
Data is stored in nutrition/{year} docs with MMDD keys.
Sourcepub async fn get_food_log(&mut self, date: NaiveDate) -> Result<Vec<FoodEntry>>
pub async fn get_food_log(&mut self, date: NaiveDate) -> Result<Vec<FoodEntry>>
Get food log entries for a specific date.
Data is stored in food/{YYYY-MM-DD} docs.
Sourcepub async fn get_steps(
&mut self,
start: NaiveDate,
end: NaiveDate,
) -> Result<Vec<StepEntry>>
pub async fn get_steps( &mut self, start: NaiveDate, end: NaiveDate, ) -> Result<Vec<StepEntry>>
Get step counts for a date range.
Data is stored in steps/{year} docs with MMDD keys.
Sourcepub async fn get_goals(&mut self) -> Result<Goals>
pub async fn get_goals(&mut self) -> Result<Goals>
Get the current macro/calorie goals from the user’s planner.
Sourcepub async fn log_food(
&mut self,
logged_at: DateTime<Local>,
name: &str,
calories: f64,
protein: f64,
carbs: f64,
fat: f64,
) -> Result<()>
pub async fn log_food( &mut self, logged_at: DateTime<Local>, name: &str, calories: f64, protein: f64, carbs: f64, fat: f64, ) -> Result<()>
Log a food entry for a given date and time.
Pass logged_at as the local datetime when the food was consumed —
the caller is responsible for providing the correct timezone.
Use chrono::Local::now() for the current time.
Fields like calories, protein, carbs, fat are required.
The entry will be created with a timestamp-based ID.
Sourcepub async fn log_weight(
&mut self,
date: NaiveDate,
weight_kg: f64,
body_fat: Option<f64>,
) -> Result<()>
pub async fn log_weight( &mut self, date: NaiveDate, weight_kg: f64, body_fat: Option<f64>, ) -> Result<()>
Log a weight entry for a given date. Weight should be in kg.
Sourcepub async fn delete_weight_entry(&mut self, date: NaiveDate) -> Result<()>
pub async fn delete_weight_entry(&mut self, date: NaiveDate) -> Result<()>
Delete a weight entry for a given date.
Removes the MMDD field from the scale/{year} document.
Sourcepub async fn log_nutrition(
&mut self,
date: NaiveDate,
calories: f64,
protein: Option<f64>,
carbs: Option<f64>,
fat: Option<f64>,
) -> Result<()>
pub async fn log_nutrition( &mut self, date: NaiveDate, calories: f64, protein: Option<f64>, carbs: Option<f64>, fat: Option<f64>, ) -> Result<()>
Import a manual nutrition summary for a given date.
This writes to the nutrition/{year} collection, which is used for
externally imported nutrition data (e.g. Apple Health syncs).
The app computes daily totals from individual food entries automatically —
you do NOT need to call this after logging food.
Sourcepub async fn search_foods(&self, query: &str) -> Result<Vec<SearchFoodResult>>
pub async fn search_foods(&self, query: &str) -> Result<Vec<SearchFoodResult>>
Search the food database using Typesense.
Searches both common_foods and branded_foods collections.
No authentication required — uses the Typesense API key directly.
Sourcepub async fn log_searched_food(
&mut self,
logged_at: DateTime<Local>,
food: &SearchFoodResult,
serving: &FoodServing,
quantity: f64,
) -> Result<()>
pub async fn log_searched_food( &mut self, logged_at: DateTime<Local>, food: &SearchFoodResult, serving: &FoodServing, quantity: f64, ) -> Result<()>
Log a food entry from a search result.
serving specifies which serving option to use (from food.servings or food.default_serving).
quantity is how many of that serving (e.g. 1.0 for one serving).
Trait Implementations§
Source§impl Clone for MacroFactorClient
impl Clone for MacroFactorClient
Source§fn clone(&self) -> MacroFactorClient
fn clone(&self) -> MacroFactorClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more