use journal::types::{Consumer, Experience, Journal}; use crate::formatting::{format_ingestion_dose, format_ingestion_roa, format_ingestion_time}; pub fn print_ingestion_log( journal: &Journal, experience: &Experience, substance_filter: Option<&Vec>, consumer_filter: Option<&Vec>, ) { for ingestion in experience.ingestions.iter() { if let Some(substance_filter) = substance_filter { if !substance_filter.contains(&ingestion.substance_name) { continue; } } if let Some(consumer_filter) = consumer_filter { if !consumer_filter.contains(&ingestion.consumer) { continue; } } let custom_unit = journal.maybe_custom_unit(ingestion); //println!("{:#?} {:#?}", &ingestion, &custom_unit); println!( "{}|{}|{}|{}|{}", ingestion.substance_name, format_ingestion_dose(&ingestion.dose, custom_unit.as_ref().map(|f| &f.dose)), format_ingestion_roa(ingestion, custom_unit.as_ref()), ingestion.consumer, format_ingestion_time(ingestion) ) } }