fetch_arch_news

Function fetch_arch_news 

Source
pub async fn fetch_arch_news(
    limit: usize,
    cutoff_date: Option<&str>,
) -> Result<Vec<NewsItem>, Box<dyn Error + Send + Sync>>
Expand description

What: Fetch recent Arch Linux news items with optional early date filtering.

Input:

  • limit: Maximum number of items to return (best-effort)
  • cutoff_date: Optional date string (YYYY-MM-DD) for early filtering

Output: Ok(Vec<NewsItem>) with date/title/url; Err on network or parse failures

ยงErrors

  • Returns Err when network request fails (curl execution error)
  • Returns Err when RSS feed cannot be fetched from Arch Linux website
  • Returns Err when response body cannot be decoded as UTF-8

Details: Downloads the Arch Linux news RSS feed and iteratively parses <item> blocks, extracting <title>, <link>, and <pubDate>. The pubDate value is normalized to a date-only form via strip_time_and_tz. If cutoff_date is provided, stops fetching when items exceed the date limit.