use ogrim_macros::xml; fn main() { println!("{}", make_rss().unwrap()); } fn make_rss() -> Result { // Make format dependent on CLI parameter. let format = if std::env::args().nth(1).is_some_and(|s| s == "--pretty") { ogrim::Format::Pretty { indentation: " " } } else { ogrim::Format::Terse }; let buf = xml!( #[format = format] "Foxxo Weekly"</> <link>"https://foxxo.tv/podcast"</> <description>"Your weekly talk about the cutest animal."</> <language>"en"</> <itunes:explicit>"false"</> <itunes:image href="https://foxxo.tv/cover.jpg" /> <itunes:category text="Education" /> <atom:link href={"https://foxxo.tv/podcast/rss.xml"} rel="self" type="application/rss+xml" /> // Both functions only return `Result` to show that using `?` // works here (just like `.await`). {|buf| emit_episodes(buf)?} </channel> </rss> ); Ok(buf.into_string()) } fn emit_episodes(doc: &mut ogrim::Document) -> Result<(), ()> { let episodes = [ "The classic: red fox", "Visiting an arctic fox", "How big media tries to lure fox enthusiasts into bullshit news", "Fennec fox has big ears & a big heart <3", ]; for title in episodes { xml!(doc, <item> <title>{title}</> // ... other RSS stuff </> ); } Ok(()) }