macro_rules! macro_generate_rss {
($writer:expr, $options:expr) => { ... };
}Expand description
Generates an RSS feed from the given RssData struct.
This macro generates a complete RSS feed in XML format based on the data contained in the provided RssData.
It dynamically generates XML elements for each field of the RssData using the provided metadata values and
writes them to the specified Writer instance.
§Arguments
$writer- The Writer instance to write the generated XML events.$options- TheRssDatainstance containing the metadata values for generating the RSS feed.
§Returns
Returns Result<Writer<std::io::Cursor<Vec<u8>>>, Box<dyn Error>> indicating success or an error if XML writing fails.
§Example
use rss_gen::{RssData, macro_generate_rss, macro_write_element};
use quick_xml::Writer;
use std::io::Cursor;
fn generate_rss() -> Result<(), Box<dyn std::error::Error>> {
let mut writer = Writer::new(Cursor::new(Vec::new()));
let options = RssData::new()
.Title("My Blog")
.Link("https://example.com")
.Description("A blog about Rust");
let result: Result<Writer<Cursor<Vec<u8>>>, Box<dyn std::error::Error>> = macro_generate_rss!(writer, options);
assert!(result.is_ok());
Ok(())
}
```text
generate_rss().unwrap();