use uuid::Uuid; use chrono::prelude::*; // Content strings to add to html pub const TITLE: &str = r#"Catgirl Cooking"#; pub const HEADER: &str = r#"🥘 Catgirl Cooking"#; pub const DESCRIPTION: &str = r#"The cutest cooking site on the net :3"#; pub const DETAILS: &str = r#"Absolutely no ads, tracking, or nazis, ever."#; pub enum TimeUnits { Hours, Min, Sec, } pub enum MeasurementUnits { Grams, Kilograms, Pounds, Litres, Millilitres, Gallons, Ounces, Pinch, Drop, Tablespoon, Teaspoon, } #[derive(Debug, PartialEq, Clone)] pub struct Tag(pub char, pub String); impl Tag { pub fn new(s: String) -> Tag { Tag('#', s) } pub fn to_string(&self) -> String { let mut tag = String::new(); tag.push_str(&self.0.to_string()); tag.push_str(&self.1); return tag; } pub fn from_string(s: String) -> Tag { let hash = s.chars().nth(0).unwrap(); let mut text = s; text.remove(0); text.make_ascii_lowercase(); return Tag(hash, text); } pub fn display(&self) { println!("{}{}", self.0, self.1); } } pub struct Recipe { id: Uuid, // Unique recipe ID name: String, // Full recipe name prep_time: (i32, TimeUnits), // Preparation time: (value, units) cooking_time: (i32, TimeUnits), // Cooking time: (value, units) servings: u8, // How many servinge the recipe makes ingredients: Vec<(i32, MeasurementUnits, String)>, // Vector of ingredients: (value, units, name) directions: Vec<(u16, String)>, // List of instructions: (step #, details) attribution: String, // Author name posted_date: DateTime, // Date the recipe was first posted edited_date: DateTime, // Date the recipe was last edited tags: Vec, // List of tags }