feedparser-rs 0.8.0

High-performance RSS/Atom/JSON Feed parser
Documentation
use std::collections::HashMap;

/// HTTP response from feed fetch
#[derive(Debug, Clone)]
#[non_exhaustive]
pub struct FeedHttpResponse {
    /// HTTP status code
    pub status: u16,
    /// Final URL after redirects
    pub url: String,
    /// Response headers
    pub headers: HashMap<String, String>,
    /// Response body
    pub body: Vec<u8>,
    /// `ETag` header value
    pub etag: Option<String>,
    /// Last-Modified header value
    pub last_modified: Option<String>,
    /// Content-Type header value
    pub content_type: Option<String>,
}

impl FeedHttpResponse {
    /// Creates a response for `status` and the final `url`, with no headers or body.
    ///
    /// # Examples
    ///
    /// ```
    /// use feedparser_rs::http::FeedHttpResponse;
    ///
    /// let response = FeedHttpResponse::new(200, "https://example.com/feed.xml");
    /// assert!(response.body.is_empty());
    /// ```
    #[must_use]
    pub fn new(status: u16, url: impl Into<String>) -> Self {
        Self {
            status,
            url: url.into(),
            headers: HashMap::new(),
            body: Vec::new(),
            etag: None,
            last_modified: None,
            content_type: None,
        }
    }
}