Skip to main content

macro_generate_rss

Macro macro_generate_rss 

Source
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 (impl std::io::Write) to write the generated XML.
  • $options - The RssData instance containing the metadata values for generating the RSS feed.

§Returns

Returns Result<W, E> indicating success or an error if XML writing fails.

§Example

use rss_gen::{RssData, macro_generate_rss, macro_write_element};
use std::io::Cursor;

fn generate_rss() -> Result<(), Box<dyn std::error::Error>> {
    let writer = Cursor::new(Vec::new());
    let options = RssData::new(None)
        .title("My Blog")
        .link("https://example.com")
        .description("A blog about Rust");

    let result: Result<Cursor<Vec<u8>>, Box<dyn std::error::Error>> = macro_generate_rss!(writer, options);
    assert!(result.is_ok());
    Ok(())
}