use thiserror::Error; #[derive(Debug, Error)] pub enum DomainError { #[error("database error: {0}")] Database(String), #[error("password error: {0}")] Password(String), #[error("record not found")] NotFound, #[error("record already exists")] Conflict, } pub type DomainResult = Result; #[derive(Clone, Debug)] pub struct User { pub id: i64, pub email: String, pub display_name: String, /// Opaque, random user handle used as the WebAuthn userHandle. Kept /// high-entropy and unpredictable per the WebAuthn spec to avoid user /// enumeration and cross-site correlation. Stored as raw bytes. pub user_handle: Vec, } #[derive(Clone, Debug)] pub struct Passkey { pub id: i64, pub user_id: i64, pub credential_id: String, pub credential: String, /// WebAuthn sign counter, persisted for future cloned-authenticator /// detection. Not currently read by application logic. #[allow(dead_code)] pub counter: i64, } #[derive(Clone, Debug)] pub struct SessionUser { pub user: User, pub csrf_token: String, } #[derive(Clone, Debug)] pub struct GroceryList { pub id: i64, pub name: String, pub revision: i64, /// Unix timestamp of when the list was created. pub created_at: i64, /// Unix timestamp of when the list was archived; `None` when active. pub archived_at: Option, } #[derive(Clone, Debug)] pub struct Item { pub id: i64, pub list_id: i64, pub name: String, pub quantity: String, pub note: String, pub category_id: Option, pub checked: bool, pub version: i64, } #[derive(Clone, Debug)] pub struct Category { pub id: i64, pub name: String, } #[derive(Clone, Debug)] pub struct MealCategory { pub id: i64, pub name: String, } #[derive(Clone, Debug)] pub struct Meal { pub id: i64, pub name: String, pub description: String, pub category_id: Option, pub ingredients: Vec, } #[derive(Clone, Debug)] pub struct MealIngredient { pub id: i64, pub name: String, pub quantity: String, pub note: String, pub category_id: Option, } #[derive(Clone, Debug)] pub struct ListMeal { pub id: i64, /// The catalog meal this instance came from; `None` once the meal is deleted. #[allow(dead_code)] pub meal_id: Option, pub name: String, /// Whether the meal has been eaten (checked off) on this list. pub checked: bool, /// When the meal was added to the list. #[allow(dead_code)] pub created_at: i64, } #[derive(Clone, Debug)] pub struct PresenceUser { pub user_id: i64, pub display_name: String, } /// A stored rewards-card number that can be shown as a scannable barcode. #[derive(Clone, Debug)] pub struct RewardsCard { pub id: i64, /// The owner of this card. #[allow(dead_code)] pub user_id: i64, pub store_name: String, pub number: String, /// Symbology used to render the barcode (e.g. "code128", "code39"). pub symbology: String, /// When the card was added. #[allow(dead_code)] pub created_at: i64, }