Skip to main content

detect_feed_format

Function detect_feed_format 

Source
pub fn detect_feed_format(xml: &str) -> FeedFormat
Expand description

Peeks the root element of an XML document and returns the detected FeedFormat.

This is a lightweight heuristic intended for dispatching between crate::generator::generate_rss / crate::parser::parse_rss and the Atom code path. It reads only as far as the first start element and does not validate the document.

ยงExamples

use rss_gen::atom::{detect_feed_format, FeedFormat};

let rss = r#"<?xml version="1.0"?><rss version="2.0"><channel/></rss>"#;
assert_eq!(detect_feed_format(rss), FeedFormat::Rss);

let atom = r#"<?xml version="1.0"?><feed xmlns="http://www.w3.org/2005/Atom"/>"#;
assert_eq!(detect_feed_format(atom), FeedFormat::Atom);