use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; use sqlx::FromRow; use uuid::Uuid; use super::patch::Patch; #[derive(Debug, Clone, Serialize, Deserialize, FromRow)] pub struct Collection { pub id: Uuid, pub user_id: Uuid, pub name: String, pub description: Option, pub created_at: DateTime, pub updated_at: DateTime, } /// Shape returned by `GET /me/collections`. Enriched with the manga /// count and up to three sample cover paths so a collection card can /// render without extra round-trips. #[derive(Debug, Clone, Serialize, FromRow)] pub struct CollectionSummary { pub id: Uuid, pub user_id: Uuid, pub name: String, pub description: Option, pub created_at: DateTime, pub updated_at: DateTime, pub manga_count: i64, /// Cover image keys of up to three sample mangas (newest-added /// first). `Vec` rather than `Option<...>` so an empty /// collection renders as `[]` rather than `null`. pub sample_covers: Vec, } #[derive(Debug, Clone, Deserialize)] pub struct NewCollection { pub name: String, #[serde(default)] pub description: Option, } #[derive(Debug, Clone, Deserialize, Default)] pub struct CollectionPatch { pub name: Option, /// Three-state: missing key leaves description alone; explicit /// `null` clears it; a string sets it. See `Patch`. #[serde(default)] pub description: Patch, }