rss_gen

Function quick_rss

Source
pub fn quick_rss(title: &str, link: &str, description: &str) -> Result<String>
Expand description

A convenience function to generate a minimal valid RSS 2.0 feed.

This function creates an RSS 2.0 feed with the provided title, link, and description, and includes one example item.

§Arguments

  • title - The title of the RSS feed.
  • link - The link to the website associated with the RSS feed.
  • description - A brief description of the RSS feed.

§Returns

A Result containing the generated RSS feed as a String if successful, or an RssError if generation fails.

§Examples

use rss_gen::quick_rss;

let rss = quick_rss(
    "My Rust Blog",
    "https://myrustblog.com",
    "A blog about Rust programming"
);

match rss {
    Ok(feed) => println!("Generated RSS feed: {}", feed),
    Err(e) => eprintln!("Error: {}", e),
}

§Errors

This function will return an error if:

  • Any of the input strings are empty
  • Any of the input strings exceed their respective maximum lengths
  • The link is not a valid URL starting with “http://” or “https://”
  • RSS generation fails for any reason

§Security

This function performs basic input validation, but it’s recommended to sanitize the input parameters before passing them to this function, especially if they come from untrusted sources.