use serde::Serialize; use time::OffsetDateTime; use super::{content::Content, link::Link}; #[derive(Debug, Serialize)] #[serde(rename = "entry")] pub struct Entry { pub title: String, pub id: String, #[serde(with = "time::serde::rfc3339")] pub updated: OffsetDateTime, pub content: Content, #[serde(rename = "link")] pub links: Vec, } #[cfg(test)] mod tests { use quick_xml::se::to_string; use time::macros::datetime; use crate::opds::{content::Content, media_type::MediaType, relation::Relation}; use super::*; fn init() -> Entry { Entry { title: "Authors".to_string(), id: "rust:authors".to_string(), updated: datetime!(2024-05-06 19:14:54 UTC), content: Content { media_type: MediaType::Text, content: "All authors".to_string(), }, links: vec![ Link { href: "/opds".to_string(), media_type: MediaType::Text, rel: Relation::Start, title: None, count: None, }, Link { href: "/opds".to_string(), media_type: MediaType::Text, rel: Relation::Start, title: None, count: None, }, ], } } #[test] fn serialize() { let entry = init(); let xml = to_string(&entry).unwrap(); assert_eq!( xml, r#"Authorsrust:authors2024-05-06T19:14:54ZAll authors"# ); } }